[Esbox-commits] r896 - in branches/sdkPlusSupport: . org.maemo.esbox.maemosdk.core org.maemo.esbox.maemosdk.core/.settings org.maemo.esbox.maemosdk.core/META-INF org.maemo.esbox.maemosdk.core/conf org.maemo.esbox.maemosdk.core/src org.maemo.esbox.maemosdk.core/src/org org.maemo.esbox.maemosdk.core/src/org/maemo org.maemo.esbox.maemosdk.core/src/org/maemo/esbox org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk/core org.maemo.esbox.scratchbox.sb1 org.maemo.esbox.scratchbox.sb1/META-INF org.maemo.esbox.scratchbox.sb1/conf org.maemo.esbox.scratchbox.sb1/src org.maemo.esbox.scratchbox.sb1/src/org org.maemo.esbox.scratchbox.sb1/src/org/maemo org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1 org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/preferences org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1 org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1/sdk org.maemo.esbox.scratchbox.sb2 org.maemo.esbox.scratchbox.sb2/META-INF org.maemo.esbox.scratchbox.sb2/conf org.maemo.esbox.scratchbox.sb2/icons org.maemo.esbox.scratchbox.sb2/icons/full org.maemo.esbox.scratchbox.sb2/icons/full/obj16 org.maemo.esbox.scratchbox.sb2/src org.maemo.esbox.scratchbox.sb2/src/org org.maemo.esbox.scratchbox.sb2/src/org/maemo org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2 org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2/core org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2 org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/preferences org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2 org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk

baranov at garage.maemo.org baranov at garage.maemo.org
Mon Oct 27 09:28:56 EET 2008


Author: baranov
Date: 2008-10-27 09:28:55 +0200 (Mon, 27 Oct 2008)
New Revision: 896

Added:
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.classpath
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.project
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.settings/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.settings/org.eclipse.jdt.core.prefs
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/META-INF/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/META-INF/MANIFEST.MF
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/build.properties
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/conf/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/conf/maemo_prefs.xml
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/plugin.xml
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoEnvironmentUtils.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceConstantsPrivate.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceMigrator.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/BaseScratchboxExecutionEnvironment.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/GTKExecutionEnvironment.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/MaemoExecutionEnvironment.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/X11ExecutionEnvironment.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoLauncher.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoScriptLauncher.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/Activator.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleProjectProperties.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleWorkspaceProjectPropertiesProvider.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentAdapter.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentFactory.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapter.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapterFactory.java
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk/core/
   branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk/core/MaemoPreferenceConstants.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.classpath
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.project
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.settings/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/META-INF/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/META-INF/MANIFEST.MF
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/build.properties
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/run.sh
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/sb1_prefs.xml
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/plugin.xml
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/AbstractSB1Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/CreateTargetCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetGdbQemuCommandPatternCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetVersionScratchboxCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/KillallCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCompilersCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCputranspCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListDevkitsCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListSessionsCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListTargetsCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RemoveTargetCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ResetTargetCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RootstrapCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/SelectTargetCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ShowTargetCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/SB1PreferenceConstants.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1FileSystemMapping.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDKTarget.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1EnvironmentProvider.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncher.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncherFactory.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapterFactory.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapter.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapterFactory.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/preferences/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/preferences/Scratchbox1PreferencesPage.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/TargetWizardDevkitsPage.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1/sdk/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1/sdk/IScratchbox1SDK.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.classpath
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.project
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.settings/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/META-INF/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/META-INF/MANIFEST.MF
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/build.properties
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/conf/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/conf/sb2_prefs.xml
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/icons/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/icons/full/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/icons/full/obj16/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/icons/full/obj16/maemoprj_obj.png
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/plugin.xml
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2/core/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2/core/SB2PreferenceConstants.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/Activator.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/AbstractSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateTargetSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetCurrentTargetSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetGdbQemuCommandPatternCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetMaemoRootstrapLocationCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetVersionScratchboxCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCompilersSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCputranspSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListTargetsCommand.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/MaemoRootstrapSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveMaemoRootstrapSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveTargetSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ShowPathMappingSb2Command.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2FileSystemMapping.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDK.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2EnvironmentProvider.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncher.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncherFactory.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapterFactory.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/preferences/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/preferences/Scratchbox2PreferencesPage.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/NewScratchbox2TargetWizard.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/IScratchbox2SDK.java
   branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/MaemoRootstrap.java
Log:
initial import

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.classpath
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.classpath	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.classpath	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.project
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.project	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.project	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.maemo.esbox.maemosdk.core</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/.settings/org.eclipse.jdt.core.prefs	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,7 @@
+#Mon Oct 20 13:39:01 CDT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/META-INF/MANIFEST.MF
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/META-INF/MANIFEST.MF	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/META-INF/MANIFEST.MF	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ESbox Maemo SDK Core Plug-in
+Bundle-SymbolicName: org.maemo.esbox.maemosdk.core;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.maemo.esbox.internal.maemosdk.core.Activator
+Bundle-Vendor: INdT / NOKIA
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.maemo.mica.common.core;bundle-version="2.0.0",
+ org.maemo.mica.common.project.core;bundle-version="2.0.0",
+ org.maemo.mica.common.launch;bundle-version="2.0.0",
+ org.maemo.mica.protocol.sbrsh;bundle-version="2.0.0",
+ org.maemo.esbox.scratchbox.core;bundle-version="2.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Export-Package: org.maemo.esbox.internal.api.maemosdk.core.tools;x-friends:="org.maemo.esbox.scratchbox.sb1",
+ org.maemo.esbox.maemosdk.core

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/build.properties
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/build.properties	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/build.properties	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/conf/maemo_prefs.xml
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/conf/maemo_prefs.xml	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/conf/maemo_prefs.xml	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+
+<properties>
+	<comment>This file contains the default settings for Maemo-specific preferences; 
+	see the org.maemo.mica.common.core.preference_set_provider extension</comment>
+	
+	<!-- others commands -->	
+	<entry key="DISPLAY_X_COMMAND_UNIX">Xephyr ${DISPLAY} -host-cursor -screen 800x480x16 -dpi 96 -ac -extension Composite</entry>
+	<entry key="DISPLAY_X_COMMAND_WIN32">c:/cygwin/usr/X11R6/bin/Xwin ${DISPLAY} -lesspointer -swcursor -screen 0 800x480x16 -dpi 96 -ac -extension Composite</entry>
+	<!-- this is initialized dynamically <entry key="DISPLAY_X_COMMAND"></entry> -->
+	
+	<!-- others commands -->	
+	<entry key="X_DISPLAY">:2</entry>
+	<entry key="X_PATH_WIN32">c:/cygwin/bin</entry>
+	<entry key="X_PATH_UNIX"></entry>
+	<!-- this is initialized dynamically <entry key="X_PATH"></entry> -->
+	
+	<entry key="MAEMO_COMMAND">af-sb-init.sh ${ACTIONS}</entry>
+	<entry key="MAEMO_START_ACTION">start</entry>
+	<entry key="MAEMO_RESTART_ACTION">restart</entry>
+	<entry key="MAEMO_STOP_ACTION">stop</entry>
+</properties>

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/plugin.xml
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/plugin.xml	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/plugin.xml	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension
+         point="org.eclipse.core.runtime.adapters">
+       <factory
+            adaptableType="org.maemo.mica.common.core.sdk.ISDKTarget"
+            class="org.maemo.esbox.internal.maemosdk.core.adapters.MaemoTargetEnvironmentModifierAdapterFactory">
+         <adapter
+               type="org.maemo.mica.common.launch.adapters.ITargetEnvironmentModifierAdapter">
+         </adapter>
+      </factory>
+   </extension>
+
+  <extension
+         id="org.maemo.mica.common.core.execution_environments"
+         name="name"
+         point="org.maemo.mica.common.core.execution_environment">
+      <execution_environment
+      		id="x11"
+            class="org.maemo.esbox.internal.api.maemosdk.core.execEnv.X11ExecutionEnvironment">
+      </execution_environment>
+      <execution_environment
+      		id="gtk"
+            class="org.maemo.esbox.internal.api.maemosdk.core.execEnv.GTKExecutionEnvironment">
+      </execution_environment>
+      <execution_environment
+      		id="maemo"
+            class="org.maemo.esbox.internal.api.maemosdk.core.execEnv.MaemoExecutionEnvironment">
+      </execution_environment>
+   </extension>
+  
+   <extension
+         point="org.eclipse.core.runtime.adapters">
+       <factory
+            adaptableType="org.maemo.mica.common.core.sdk.ISDKTarget"
+            class="org.maemo.esbox.internal.maemosdk.core.adapters.MaemoDefaultExecutionEnvironmentFactory">
+         <adapter
+               type="org.maemo.mica.common.core.adapters.IDefaultExecutionEnvironmentAdapter">
+         </adapter>
+       </factory>
+   </extension>
+
+  <extension
+        point="org.maemo.mica.common.core.preference_set_provider">
+     <preferenceSetProvider
+           defaultsXMLFile="conf/maemo_prefs.xml"
+           preferenceConstantsClass="org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants"
+           preferenceMigratorClass="org.maemo.esbox.internal.api.maemosdk.core.MaemoPreferenceMigrator"
+           preferenceStoreBundle="org.maemo.esbox.maemosdk.core"
+           version="17">
+     </preferenceSetProvider>
+  </extension>
+
+  <extension
+        point="org.maemo.mica.common.project.core.oldStyleProjectPropertiesProvider">
+     <projectPropertiesProvider
+           class="org.maemo.esbox.internal.maemosdk.core.OldStyleWorkspaceProjectPropertiesProvider">
+     </projectPropertiesProvider>
+  </extension>
+
+  
+</plugin>

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoEnvironmentUtils.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoEnvironmentUtils.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoEnvironmentUtils.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core;
+
+import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.mica.common.core.CorePreferenceManager;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.machine.IMachine;
+
+/**
+ * @author eswartz
+ *
+ */
+public class MaemoEnvironmentUtils {
+	/**
+	 * Define DISPLAY for launches under the emulator that need a connection to the X server.
+	 * <p>
+	 * This uses the setting from the X Server preferences.
+	 * @param serverMachine the machine that hosts X
+	 * @param envBlock
+	 */
+	public static void defineEmulatorXDisplayVariable(IMachine serverMachine, IEnvironmentModifierBlock envBlock) {
+		// local launches need DISPLAY that points back to the host machine
+		String display = CorePreferenceManager.getInstance().getRegisteredKeyValue(
+				MaemoPreferenceConstants.X_DISPLAY);
+		if (display != null && display.length() > 0) {
+			String host = serverMachine.getLocalMachineAddress();
+			if (host.equals(IMachine.LOCALHOST_ADDRESS)) {
+				host = "";
+			}
+			envBlock.define("DISPLAY", host + display);
+		}
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceConstantsPrivate.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceConstantsPrivate.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceConstantsPrivate.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core;
+
+/**
+ * Private constants for preference migration 
+ * @author eswartz
+ *
+ */
+public class MaemoPreferenceConstantsPrivate {
+	/* OS-specific defaults */
+	static final String DISPLAY_X_COMMAND_WIN32 = "DISPLAY_X_COMMAND_WIN32";
+	static final String DISPLAY_X_COMMAND_UNIX = "DISPLAY_X_COMMAND_UNIX";
+	static final String X_PATH_WIN32 = "X_PATH_WIN32";
+	static final String X_PATH_UNIX = "X_PATH_UNIX";
+
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceMigrator.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceMigrator.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/MaemoPreferenceMigrator.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core;
+
+import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.mica.common.core.HostUtils;
+import org.maemo.mica.common.core.IPreferenceMigrator;
+import org.maemo.mica.internal.api.common.core.OldESboxPreferenceMigrator;
+
+import java.util.Properties;
+
+/**
+ * To migrate preferences, we use the 1.4 -> newer conversion and also pick an
+ * OS-specific initial value for the X server command.
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoPreferenceMigrator extends OldESboxPreferenceMigrator
+		implements IPreferenceMigrator {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.OldESboxPreferenceMigrator#
+	 * adjustDefaultSettings(java.util.Properties)
+	 */
+	@Override
+	public void adjustDefaultSettings(Properties newPropertyDefaults) {
+		super.adjustDefaultSettings(newPropertyDefaults);
+		// adjust any environment-dependent defaults
+		String hostEnvKey;
+		if (HostUtils.isWindows())
+			hostEnvKey = MaemoPreferenceConstantsPrivate.DISPLAY_X_COMMAND_WIN32;
+		else
+			hostEnvKey = MaemoPreferenceConstantsPrivate.DISPLAY_X_COMMAND_UNIX;
+		newPropertyDefaults.put(MaemoPreferenceConstants.DISPLAY_X_COMMAND,
+				newPropertyDefaults.getProperty(hostEnvKey));
+		
+		if (HostUtils.isWindows())
+			hostEnvKey = MaemoPreferenceConstantsPrivate.X_PATH_WIN32;
+		else
+			hostEnvKey = MaemoPreferenceConstantsPrivate.X_PATH_UNIX;
+		newPropertyDefaults.put(MaemoPreferenceConstants.X_PATH, 
+				newPropertyDefaults.getProperty(hostEnvKey));
+		
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/BaseScratchboxExecutionEnvironment.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/BaseScratchboxExecutionEnvironment.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/BaseScratchboxExecutionEnvironment.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core.execEnv;
+
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+import org.maemo.mica.common.core.execEnv.BaseExecutionEnvironment;
+
+/**
+ * @author eswartz
+ * 
+ */
+public abstract class BaseScratchboxExecutionEnvironment extends
+		BaseExecutionEnvironment {
+	/** Base id for scratchbox execution environment ids */
+	public static final String SB_EXEC_ENV_BASE = Activator.PLUGIN_ID;
+
+	public BaseScratchboxExecutionEnvironment(String id, String name) {
+		super(id, name);
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/GTKExecutionEnvironment.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/GTKExecutionEnvironment.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/GTKExecutionEnvironment.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core.execEnv;
+
+/**
+ * Environment for GTK applications in X11
+ * 
+ * @author eswartz
+ * 
+ */
+public class GTKExecutionEnvironment extends X11ExecutionEnvironment {
+	@SuppressWarnings("hiding")
+	public static final String ID = SB_EXEC_ENV_BASE + ".gtk";
+
+	public GTKExecutionEnvironment() {
+		super(ID, "GTK");
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/MaemoExecutionEnvironment.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/MaemoExecutionEnvironment.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/MaemoExecutionEnvironment.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core.execEnv;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.internal.api.maemosdk.core.tools.MaemoScriptLauncher;
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.project.core.ProjectManager;
+
+/**
+ * Environment for Maemo applications
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoExecutionEnvironment extends X11ExecutionEnvironment {
+	@SuppressWarnings("hiding")
+	public static final String ID = SB_EXEC_ENV_BASE + ".maemo";
+
+	public MaemoExecutionEnvironment() {
+		super(ID, "Maemo");
+	}
+
+	public MaemoExecutionEnvironment(String id, String name) {
+		super(id, name);
+	}
+
+	@Override
+	public void establishEnvironment(Shell shell, IProject project)
+			throws CoreException {
+		// see if Maemo is running
+		ISDKTarget sdkTarget;
+		try {
+			sdkTarget = ProjectManager.getInstance().getSDKTarget(project);
+			if (!MaemoScriptLauncher.getInstance().isMaemoStarted(sdkTarget)) {
+				if (MessageDialog
+						.openQuestion(shell, "Launch Maemo?",
+								"Maemo is not running.  Would you like to launch it now?")) {
+					MaemoScriptLauncher.getInstance().startMaemo(sdkTarget);
+				}
+			}
+		} catch (MicaException e) {
+			Activator.getErrorLogger().logAndShowError(
+					"Error querying Maemo status", e);
+			// don't fail the launch
+		}
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/X11ExecutionEnvironment.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/X11ExecutionEnvironment.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/execEnv/X11ExecutionEnvironment.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core.execEnv;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.internal.api.maemosdk.core.tools.MaemoScriptLauncher;
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.project.core.ProjectManager;
+
+/**
+ * Environment for X11-based programs
+ * 
+ * @author eswartz
+ * 
+ */
+public class X11ExecutionEnvironment extends BaseScratchboxExecutionEnvironment {
+
+	/**
+	 * 
+	 */
+	public static final String ID = SB_EXEC_ENV_BASE + ".x11";
+
+	public X11ExecutionEnvironment() {
+		super(ID, "X11");
+	}
+
+	public X11ExecutionEnvironment(String id, String name) {
+		super(id, name);
+	}
+
+	@Override
+	public void establishEnvironment(Shell shell, IProject project)
+			throws CoreException {
+		super.establishEnvironment(shell, project);
+
+		ISDKTarget sdkTarget;
+		try {
+			sdkTarget = ProjectManager.getInstance().getSDKTarget(project);
+		} catch (MicaException e1) {
+			throw new CoreException(Activator.createErrorStatus(
+					"Not an ESbox project: " + project, e1));
+		}
+
+		try {
+			if (!MaemoScriptLauncher.getInstance().isXServerStarted(sdkTarget)) {
+
+				if (MessageDialog
+						.openQuestion(shell, "Launch X Server?",
+								"The X server is not running.  Would you like to launch it now?")) {
+					MaemoScriptLauncher.getInstance().startX();
+				}
+			}
+		} catch (MicaException e) {
+			Activator.getErrorLogger().logAndShowError(
+					"Error querying X status", e);
+			// don't fail the launch
+		}
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoLauncher.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoLauncher.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoLauncher.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,277 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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 (UFCG) - initial implementation
+ *    Ed Swartz (Nokia) - adaptation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core.tools;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.ui.console.*;
+import org.maemo.esbox.internal.api.maemosdk.core.MaemoEnvironmentUtils;
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.mica.common.core.*;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.machine.*;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+
+/**
+ * This class maintains knowledge about whether maemo is running in a target and
+ * controls access to starting, stopping, and querying status.
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoLauncher {
+
+	private static final String MAEMO_LAUNCHER_APP = "maemo-launcher";
+	private static MaemoLauncher instance;
+
+	
+	public synchronized static MaemoLauncher getInstance() {
+		if (instance == null) {
+			instance = new MaemoLauncher();
+		}
+		return instance;
+	}
+	
+	static class MaemoCommand {
+
+		private ISDKTarget sdkTarget;
+
+		public MaemoCommand(ISDKTarget sdkTarget) {
+			this.sdkTarget = sdkTarget;
+		}
+
+		private void performCommand(List<String> params) throws MicaException {
+			String maemoCommand = sdkTarget.getPreferenceValue(
+					MaemoPreferenceConstants.MAEMO_COMMAND);
+			maemoCommand = this.replaceActions(maemoCommand,params.get(0));
+			
+			IProcessLauncherFactory processLauncherFactory = sdkTarget.getProcessLauncherFactory();
+			
+			IEnvironmentModifierBlock envBlock = processLauncherFactory.defaultEnvironmentModifierBlock();
+			MaemoEnvironmentUtils.defineEmulatorXDisplayVariable(sdkTarget.getSDK().getMachine(), envBlock);
+			
+			IProcessLauncher processLauncher = ProcessLauncherCreator.createProcessLauncher(processLauncherFactory, null,
+					Collections.singletonList(maemoCommand), envBlock);
+
+			Process process = processLauncher.createProcess();
+
+			// spit the consumed output to the console
+			MessageConsole console = CoreConsoleManager.getInstance().getConsole(true,
+					sdkTarget, "Running Maemo command (" + params.get(0) + ")");
+
+			console.addPatternMatchListener(new IPatternMatchListener() {
+
+				public int getCompilerFlags() {
+					return 0;
+				}
+
+				public String getLineQualifier() {
+					return null;
+				}
+
+				public String getPattern() {
+					return "ERROR:.*";
+				}
+
+				public void connect(TextConsole console) {
+				}
+
+				public void disconnect() {
+				}
+
+				public void matchFound(PatternMatchEvent event) {
+					TextConsole console = (TextConsole) event.getSource();
+					String content;
+					try {
+						content = console.getDocument().get(event.getOffset(),
+								event.getLength());
+					} catch (BadLocationException e) {
+						content = console.getDocument().get();
+					}
+					ErrorLogger errorLogger = Activator.getErrorLogger();
+					errorLogger.logAndShowError("Error launching maemo",
+							new MicaException(content));
+				}
+
+			});
+
+			// emit everything else to the console
+			processLauncher.redirectToConsole(console);
+
+			// wait for it to finish
+			try {
+				process.waitFor();
+			} catch (InterruptedException e) {
+
+			}
+		}
+
+		public void startMaemoCommand(ISDKTarget sdkTarget) throws MicaException {
+			if (sdkTarget == null) {
+				throw new MicaException("No SDK target specified");
+			}
+
+			List<String> params = getParamList(MaemoPreferenceConstants.MAEMO_START_ACTION);
+
+			performCommand(params);
+		}
+
+		public void stopMaemoCommand(ISDKTarget sdkTarget) throws MicaException {
+			if (sdkTarget == null) {
+				throw new MicaException("No SDK target specified");
+			}
+
+			List<String> params = getParamList(MaemoPreferenceConstants.MAEMO_STOP_ACTION);
+			performCommand(params);
+		}
+
+		public void restartMaemoCommand(ISDKTarget sdkTarget)
+				throws MicaException {
+			if (sdkTarget == null) {
+				throw new MicaException("No SDK target specified");
+			}
+
+			List<String> params = getParamList(MaemoPreferenceConstants.MAEMO_RESTART_ACTION);
+			performCommand(params);
+		}
+
+		private List<String> getParamList(String key) {
+			List<String> params = new ArrayList<String>();
+			params.add(sdkTarget.getPreferenceValue(key));
+			return params;
+		}
+
+		private String replaceActions(String command, String action) {
+			return command.replaceAll("\\$\\{ACTIONS\\}", action);
+		}
+	}
+	
+
+	/**
+	 * Test whether maemo is running. We look for 'maemo-launcher' in the
+	 * process list.
+	 * 
+	 * @param sdkTarget
+	 * @return true if maemo process found
+	 * @throws MicaException
+	 *             if query is impossible
+	 */
+	private boolean testMaemoLauncher(ISDKTarget sdkTarget)
+			throws MicaException {
+		List<IProcess> runningProcesses = getMaemoLaunchers(sdkTarget.getSDK()
+				.getMachine());
+		return runningProcesses.size() > 0;
+	}
+
+	private List<IProcess> getMaemoLaunchers(IMachine machine) {
+		// includes scratchbox call that launched maemo-launcher
+		List<IProcess> runningProcesses = machine.getProcessLister()
+				.getProcesses(
+						new ProcessFilterCmdLineRegexp(".*/"
+								+ MAEMO_LAUNCHER_APP + "\\s+.*"));
+		return runningProcesses;
+	}
+
+	/**
+	 * Test whether maemo is started by testing the existence of the
+	 * maemo-launcher daemon
+	 * 
+	 * @param sdkTarget
+	 * @return flag
+	 */
+	public boolean isMaemoRunning(ISDKTarget sdkTarget) throws MicaException {
+		return testMaemoLauncher(sdkTarget);
+	}
+
+	/**
+	 * Start maemo if it's not running.
+	 * 
+	 * @param sdkTarget
+	 * @throws MicaException
+	 *             if already running or cannot be started
+	 */
+	public void startMaemo(ISDKTarget sdkTarget) throws MicaException {
+		if (isMaemoRunning(sdkTarget))
+			throw new MicaException("Maemo is already running");
+
+		MaemoCommand maemoCommand = new MaemoCommand(sdkTarget);
+		maemoCommand.startMaemoCommand(sdkTarget);
+	}
+
+	/**
+	 * Stop maemo if it's running
+	 * 
+	 * @param sdkTarget
+	 * @throws MicaException
+	 *             if not running or cannot be stopped
+	 */
+	public void stopMaemo(ISDKTarget sdkTarget) throws MicaException {
+		// always try... may be half-initialized
+		// if (!isMaemoRunning(sdkTarget))
+		// throw new
+		// ScratchboxException("Maemo is not running, or failed to launch.");
+
+		MaemoCommand maemoCommand = new MaemoCommand(sdkTarget);
+		maemoCommand.stopMaemoCommand(sdkTarget);
+	}
+
+	/**
+	 * Restart maemo
+	 * 
+	 * @param sdkTarget
+	 * @throws MicaException
+	 *             if cannot be restarted
+	 */
+	public void restartMaemo(ISDKTarget sdkTarget) throws MicaException {
+		MaemoCommand maemoCommand = new MaemoCommand(sdkTarget);
+		maemoCommand.restartMaemoCommand(sdkTarget);
+	}
+
+	/**
+	 * Kill maemo by forcibly killing instances of the launcher left behind
+	 * 
+	 * @param sdkTarget
+	 * @throws MicaException
+	 */
+	public void killMaemo(ISDKTarget sdkTarget) throws MicaException {
+		List<IProcess> pids = getMaemoLaunchers(sdkTarget.getSDK().getMachine());
+		if (pids.size() == 0)
+			return;
+
+		try {
+			for (IProcess process : pids) {
+				process.terminate();
+			}
+		} catch (IOException e) {
+
+		}
+
+		// try again
+		pids = getMaemoLaunchers(sdkTarget.getSDK().getMachine());
+		if (pids.size() == 0)
+			return;
+
+		try {
+			for (IProcess process : pids) {
+				process.kill();
+			}
+		} catch (IOException e) {
+			throw new MicaException("Could not kill " + MAEMO_LAUNCHER_APP, e);
+		}
+
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoScriptLauncher.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoScriptLauncher.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/MaemoScriptLauncher.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,749 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ui.console.MessageConsole;
+import org.maemo.mica.common.core.*;
+import org.maemo.mica.common.core.machine.*;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.*;
+import org.maemo.mica.common.project.core.ProjectManager;
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+
+/**
+ * Class handle all methods that needs some graphical environment. It invokes
+ * graphical thing that are ordered in window - preferences - Scratchbox
+ * preferences.
+ * 
+ * @author kosola modified by Raul Fernandes Herbster modified by eswartz
+ */
+public class MaemoScriptLauncher {
+
+	private static MaemoScriptLauncher singleton = null;
+
+	/**
+	 * Constructor
+	 */
+	private MaemoScriptLauncher() {
+	}
+
+	public static synchronized MaemoScriptLauncher getInstance() {
+		if (singleton == null)
+			singleton = new MaemoScriptLauncher();
+		return singleton;
+	}
+
+	/**
+	 * Method that start X-environment for Scratchbox
+	 */
+	public void startX() throws MicaException {
+
+		XLauncher.getInstance().startX(
+				CorePreferenceManager.getInstance().getPreferenceProvider());
+	}
+
+	/**
+	 * Method that stop X-environment for Scratchbox
+	 */
+	public void stopX(ISDKTarget sdkTarget) throws MicaException {
+
+		if (sdkTarget != null
+				&& MaemoLauncher.getInstance().isMaemoRunning(sdkTarget))
+			throw new MicaException("Maemo is still running. Stop Maemo first");
+
+		XLauncher.getInstance().stopX(
+				CorePreferenceManager.getInstance().getPreferenceProvider());
+	}
+
+	/**
+	 * Kill all instances of a given process
+	 * 
+	 * @param processName
+	 *            executable name
+	 * @param processLabel
+	 *            the user-visible name for the process
+	 */
+	public void killProcess(IMachine machine, String processName,
+			String processLabel) throws MicaException {
+
+		List<IProcess> processes = machine.getProcessLister().getProcesses(
+				new ProcessFilterCmdLineRegexp(".*" + processName + ".*"));
+		for (IProcess process : processes) {
+			try {
+				process.terminate();
+			} catch (IOException e) {
+				throw new MicaException("Error killing " + processName, e);
+			}
+		}
+	}
+
+	/**
+	 * Method that run command autogen.sh for the project
+	 * 
+	 * @param project
+	 * @throws MicaException
+	 */
+	public void runAutogen(IProject project) throws MicaException {
+		runAutogen(project, null, null);
+	}
+
+	/**
+	 * Method that runs command autogen.sh and waits if a progress monitor is
+	 * supplied.
+	 * 
+	 * @param project
+	 * @param monitor
+	 *            if null, do not wait; else wait and report progress through
+	 *            the monitor
+	 * @param path
+	 *            if <code>null</code> use the project path, else override to
+	 *            run autogen elsewhere
+	 * @return exit code, if monitor is not null
+	 */
+	public int runAutogen(IProject project, IProgressMonitor monitor, IPath path)
+			throws MicaException {
+		ensureBuildMachine(project, null);
+		return runScript(path != null ? path : project.getLocation(),
+				"./autogen.sh", "Running automake script (autogen.sh) ["
+						+ project.getName() + "]",
+				"Error running script autogen.sh", monitor, project);
+	}
+
+	/**
+	 * run ./configure for the project
+	 * 
+	 * @param project
+	 * @throws MicaException
+	 */
+	public void runConfigure(IProject project) throws MicaException {
+		runConfigure(project, null, null);
+	}
+
+	/**
+	 * Method that run command ./configure and wait if a progress monitor is
+	 * supplied.
+	 * 
+	 * @param project
+	 * @param monitor
+	 *            if null, do not wait; else wait and report progress through
+	 *            the monitor
+	 * @param path
+	 *            if <code>null</code>, use the project location, else override
+	 *            the directory
+	 * @return exit code, if monitor is not null
+	 * @throws MicaException
+	 */
+	public int runConfigure(IProject project, IProgressMonitor monitor,
+			IPath path) throws MicaException {
+		ensureBuildMachine(project, null);
+		return runScript(path != null ? path : project.getLocation(),
+				"./configure", "Running automake script (configure) ["
+						+ project.getName() + "]",
+				"Error running script configure", monitor, project);
+	}
+
+	/**
+	 * This method ensures that a Makefile exists in the project, by running
+	 * autogen or configure as needed. It also rebuilds Makefiles if configure
+	 * has changed, or rebuilds configure if configure.ac or autogen.sh has
+	 * changed.
+	 * 
+	 * @param project
+	 * @param monitor
+	 *            if null, do not wait; else wait and report progress through
+	 *            the monitor
+	 * @param path
+	 *            if <code>null</code> use the project path, else override to
+	 *            run scripts elsewhere
+	 * @param makefileName
+	 *            the name of the makefile to look for, or <code>null</code> for
+	 *            "Makefile"
+	 */
+	public void runEstablishAutoMakefiles(IProject project,
+			IProgressMonitor monitor, IPath path, String makefileName)
+			throws MicaException {
+
+		if (monitor == null)
+			monitor = new NullProgressMonitor();
+
+		monitor.beginTask("", 3);
+
+		// make sure machine is available
+		ensureBuildMachine(project, new SubProgressMonitor(monitor, 1));
+
+		if (path == null)
+			path = project.getLocation();
+
+		if (makefileName == null)
+			makefileName = "Makefile";
+
+		boolean triedToAutomake = false;
+
+		// XXX: the project is assumed to be visible to the remote machine, so
+		// we don't translate or use IFileStore here
+		File autogen_sh = path.append("autogen.sh").toFile();
+		File configure_ac = path.append("configure.ac").toFile();
+		File configure = path.append("configure").toFile();
+		File makefile_am = path.append(makefileName + ".am").toFile();
+		File makefile = path.append(makefileName).toFile();
+
+		boolean runAutogen = false;
+
+		if (autogen_sh.exists()
+				&& ((configure.exists() && autogen_sh.lastModified() > configure
+						.lastModified()) || (makefile.exists() && autogen_sh
+						.lastModified() > makefile.lastModified()))) {
+			// timestamps out of date (note: depend on last-generated files, not
+			// the _ac or _am
+			// ones, since autogen doesn't modify the _ac or _am files)
+			runAutogen = true;
+		} else if (configure_ac.exists() && configure.exists()
+				&& configure_ac.lastModified() > configure.lastModified()) {
+			// timestamps out of date
+			runAutogen = true;
+		} else if (configure_ac.exists() && !configure.exists()) {
+			// configure must be created
+			runAutogen = true;
+		}
+
+		boolean failedAutogen = false;
+		if (runAutogen) {
+			IProgressMonitor subMonitor = monitor != null ? new SubProgressMonitor(
+					monitor, 1)
+					: new NullProgressMonitor();
+
+			// see if autogen.sh exists
+			if (autogen_sh.exists()) {
+				if (runAutogen(project, subMonitor, path) != 0) {
+					failedAutogen = true;
+				}
+				triedToAutomake = true;
+			} else if (configure_ac.exists()) {
+				// run autoconf
+				if (runScript(path, "autoconf", "Running autoconf ["
+						+ project.getName() + "]",
+						"Error autoconfiguring project", subMonitor, project) != 0) {
+					failedAutogen = true;
+				}
+				triedToAutomake = true;
+			} else {
+				// um... either the logic is wrong or the user deleted the file
+				// in between
+			}
+		} else {
+			if (monitor != null)
+				monitor.worked(1);
+		}
+
+		boolean runConfigure = false;
+
+		if (!failedAutogen) {
+			if (configure.exists() && makefile.exists()
+					&& configure.lastModified() > makefile.lastModified()) {
+				// timestamps out of date
+				runConfigure = true;
+			} else if (makefile_am.exists() && makefile.exists()
+					&& makefile_am.lastModified() > makefile.lastModified()) {
+				// timestamps out of date
+				runConfigure = true;
+			} else if (configure.exists() && !makefile.exists()) {
+				// must create makefile
+				runConfigure = true;
+			}
+		}
+
+		boolean failedConfigure = false;
+
+		if (runConfigure) {
+			// run configure
+			IProgressMonitor subMonitor = monitor != null ? new SubProgressMonitor(
+					monitor, 1)
+					: new NullProgressMonitor();
+
+			// configure exists, so run it
+			if (runConfigure(project, subMonitor, path) != 0) {
+				failedConfigure = true;
+			}
+			triedToAutomake = true;
+		} else {
+			if (monitor != null)
+				monitor.worked(1);
+		}
+
+		// final check
+		if (failedConfigure || failedAutogen) {
+			String message = "Autogen or configure ran with errors.\nCheck the Console for autotools messages.";
+			throw new MicaException(message);
+
+		} else if (!makefile.exists()) {
+			String message = "Cannot find or create " + makefileName
+					+ " in project '" + project.getName() + "'.\n";
+			if (triedToAutomake)
+				message += "\nCheck the Console for autotools messages.";
+			throw new MicaException(message);
+		}
+
+		monitor.done();
+
+	}
+
+	/**
+	 * This doesn't invoke any code, but deletes any generated automake files so
+	 * that they will be re-run in the future.
+	 * 
+	 * @param project
+	 */
+	public void resetAutomakeState(IProject project, String makefileName) {
+		if (makefileName == null)
+			makefileName = "Makefile";
+
+		// make sure the outside build state hasn't changed in the meantime
+		try {
+			project.refreshLocal(IProject.DEPTH_ONE, new NullProgressMonitor());
+		} catch (CoreException e1) {
+			Activator.getErrorLogger().logError("Error refreshing project", e1);
+		}
+
+		// see if generated files exist
+		IFile configure_ac = project.getFile("configure.ac");
+		IFile configure = project.getFile("configure");
+		IFile makefile = project.getFile(makefileName);
+
+		if (configure_ac.exists()) {
+			try {
+				// it is an automake project
+				if (configure.exists())
+					configure.delete(true, new NullProgressMonitor());
+				if (makefile.exists())
+					makefile.delete(true, new NullProgressMonitor());
+			} catch (CoreException e) {
+				Activator.getErrorLogger().logError(
+						"Error deleting generated automake files", e);
+			}
+		} else {
+			// hmm... touch the Makefile. This isn't nice for SCM but it's all
+			// we can do besides
+			// deleting the executable, which is no nicer.
+			if (makefile.exists()) {
+				try {
+					makefile.touch(new NullProgressMonitor());
+				} catch (CoreException e) {
+					Activator.getErrorLogger().logError(
+							"Error touching Makefile", e);
+				}
+			}
+		}
+	}
+
+	/**
+	 * Validate that the project appears to be an autotools or Makefile project.
+	 * 
+	 * @param project
+	 * @return true if some key files were found.
+	 */
+	public boolean validateAutomakeState(IProject project, String makefileName) {
+		if (makefileName == null)
+			makefileName = "Makefile";
+
+		// see if generated files exist
+		IFile autogen_sh = project.getFile("autogen.sh");
+		IFile configure_ac = project.getFile("configure.ac");
+		IFile configure = project.getFile("configure");
+		IFile makefile = project.getFile(makefileName);
+
+		return autogen_sh.exists() || makefile.exists() || configure.exists()
+				|| configure_ac.exists();
+	}
+
+	/**
+	 * Run 'scriptname' in 'path' location with 'wait' for 'project'. Once
+	 * complete, refreshes the project.
+	 * 
+	 * @param path
+	 * @param scriptname
+	 *            the script, with "./" if needed
+	 * @param comment
+	 * @param errormessage
+	 * @param monitor
+	 *            if not null, wait for progress to finish
+	 * @param project
+	 * @return exit code (if monitor is not null)
+	 */
+	private int runScript(IPath path, String scriptname, final String comment,
+			String errormessage, IProgressMonitor monitor,
+			final IProject project) throws MicaException {
+		verifyFiles(new IPath[] { path.append(scriptname) });
+
+		IPath wd = path;
+
+		final ISDKTarget sdkTarget = ProjectManager.getInstance().getSDKTarget(
+				project);
+		IPath wdInScratchbox = sdkTarget.convertHostToTargetPath(wd);
+
+		IProcessLauncherFactory launcherFactory = sdkTarget
+				.getProcessLauncherFactory();
+
+		final IProcessLauncher processLauncher = ProcessLauncherCreator
+				.createProcessLauncher(launcherFactory, wdInScratchbox,
+						scriptname);
+
+		final Process process = processLauncher.createProcess();
+
+		final MessageConsole console = CoreConsoleManager.getInstance().getConsole(true,
+				sdkTarget, comment);
+
+		if (monitor == null) {
+			WorkspaceJob job = new WorkspaceJob(comment) {
+
+				@Override
+				public IStatus runInWorkspace(IProgressMonitor monitor)
+						throws CoreException {
+					monitor.beginTask("", 2);
+					monitor.subTask(comment);
+					try {
+						processLauncher.redirectToConsole(console);
+						try {
+							while (true) {
+								if (monitor.isCanceled()) {
+									process.destroy();
+									return Policy.getCancelStatus(Activator
+											.getDefault());
+								}
+								try {
+									Thread.sleep(500);
+								} catch (InterruptedException e) {
+									// ignore
+								}
+
+								try {
+									process.exitValue();
+									break;
+								} catch (IllegalThreadStateException e) {
+									// still running
+								}
+								monitor.worked(1);
+							}
+						} finally {
+							try {
+								project.refreshLocal(IResource.DEPTH_INFINITE,
+										new SubProgressMonitor(monitor, 1));
+							} catch (CoreException e) {
+								return e.getStatus();
+							}
+						}
+					} finally {
+						monitor.done();
+					}
+					return Status.OK_STATUS;
+				}
+
+			};
+			job.setRule(project);
+			job.schedule();
+			return -1;
+		} else {
+			final int[] exits = { -1 };
+			IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+				public void run(IProgressMonitor monitor) throws CoreException {
+					monitor.beginTask("", 2);
+					monitor.subTask(comment);
+					try {
+						OutputStream out = console.newOutputStream();
+						exits[0] = processLauncher.waitAndRead(out, out,
+								new SubProgressMonitor(monitor, 1));
+						project.refreshLocal(IResource.DEPTH_INFINITE,
+								new SubProgressMonitor(monitor, 1));
+					} finally {
+						monitor.done();
+					}
+				}
+
+			};
+			try {
+				ResourcesPlugin.getWorkspace().run(runnable, project, 0,
+						monitor);
+			} catch (OperationCanceledException e) {
+				// ignore
+			} catch (Exception e) {
+				throw new MicaException(e);
+			}
+			return exits[0];
+		}
+	}
+
+	/**
+	 * Create a job which will build a debian package in the project's
+	 * directory. Waits for completion.
+	 * 
+	 * @return IStatus status of build
+	 */
+	public void createDebianPackage(final IProject project,
+			IProgressMonitor monitor) throws MicaException {
+		monitor.beginTask("", IProgressMonitor.UNKNOWN);
+		monitor.subTask("Creating package");
+
+		IPath path = project.getLocation();
+
+		verifyFiles(new IPath[] { path.append("debian"),
+				path.append("debian/changelog"), path.append("debian/control"),
+				path.append("debian/rules") });
+
+		ISDKTarget target = ProjectManager.getInstance().getSDKTarget(project);
+
+		IProcessLauncherFactory launcherFactory = target
+				.getProcessLauncherFactory();
+
+		String cmd = "dpkg-buildpackage -rfakeroot -d";
+
+		// launch command inside Scratchbox
+		final IProcessLauncher processLauncher = ProcessLauncherCreator
+				.createProcessLauncher(launcherFactory, target
+						.convertHostToTargetPath(path), CommandLineArguments
+						.createFromCommandLine(cmd));
+
+		Process sbp = processLauncher.createProcess();
+
+		processLauncher.redirectToConsole(true, null, "Making Debian package ["
+				+ project.getName() + "]");
+
+		monitor.worked(1);
+
+		int exit;
+		try {
+			exit = waitForProcess(sbp, monitor);
+			if (exit != 0) {
+				throw new MicaException(
+						"Package creation failed; see Console (exit code "
+								+ exit + ")");
+			}
+			try {
+				project.refreshLocal(IResource.DEPTH_INFINITE,
+						new NullProgressMonitor());
+			} catch (CoreException e) {
+				throw new MicaException(e);
+			}
+		} catch (InterruptedException e1) {
+			throw new MicaException("Package creation interrupted");
+		}
+
+		monitor.done();
+
+	}
+
+	/**
+	 * Wait for a running process to complete, allowing user to cancel (which
+	 * kills the process)
+	 * 
+	 * @param process
+	 *            the process
+	 * @param monitor
+	 *            a progress monitor
+	 * @return exit code
+	 * @throws InterruptedException
+	 *             if process is canceled
+	 */
+	public int waitForProcess(Process process, IProgressMonitor monitor)
+			throws InterruptedException {
+		while (true) {
+			// wait a while to avoid polling
+			try {
+				Thread.sleep(500);
+			} catch (InterruptedException e) {
+				throw e;
+			}
+
+			try {
+				// see if the process terminated yet
+				return process.exitValue();
+			} catch (IllegalThreadStateException e) {
+				// thrown by #exitValue() when not finished, good
+			}
+
+			// see if user canceled
+			if (monitor.isCanceled()) {
+				process.destroy();
+				throw new InterruptedException();
+			}
+		}
+	}
+
+	private void verifyFiles(IPath[] files) throws MicaException {
+		for (IPath file : files) {
+			if (!file.toFile().exists())
+				throw new MicaException("File " + file.toPortableString()
+						+ " does not exist");
+		}
+	}
+
+	/**
+	 * Build a Debian package in the background.
+	 * 
+	 * @param project
+	 */
+	public void runCreateDebianPackage(final IProject project) {
+		WorkspaceJob job = new WorkspaceJob("Creating Debian package") {
+
+			@Override
+			public IStatus runInWorkspace(IProgressMonitor monitor)
+					throws CoreException {
+				try {
+					createDebianPackage(project, monitor);
+				} catch (MicaException e) {
+					return Activator.createErrorStatus(
+							"Failed to create Debian package", e);
+				}
+				return Status.OK_STATUS;
+			}
+
+		};
+		job.schedule();
+	}
+
+	public boolean isMaemoStarted(ISDKTarget sdkTarget) {
+		try {
+			if (!isXServerStarted(sdkTarget))
+				return false;
+		} catch (MicaException e1) {
+		}
+
+		try {
+			return MaemoLauncher.getInstance().isMaemoRunning(sdkTarget);
+		} catch (MicaException e) {
+			Activator.getErrorLogger().logError("Cannot test maemo status", e);
+			return false;
+		}
+	}
+
+	public boolean isXServerStarted(IPreferenceProvider prefProvider)
+			throws MicaException {
+		return XLauncher.getInstance().isXServerStarted(prefProvider);
+	}
+
+	/**
+	 * Get the name of the script that launches processes in a standalone
+	 * manner.
+	 * 
+	 * @param sdkTarget
+	 * @return script name, never <code>null</code>
+	 */
+	/*
+	 * public String getStandaloneScriptName(ISDKTarget sdkTarget) { return
+	 * "run-standalone.sh"; }
+	 */
+
+	/**
+	 * Tell if the target supports a "run-standalone" script.
+	 * 
+	 * @param sdkTarget
+	 * @return
+	 */
+	/*
+	 * public boolean hasRunStandaloneScript(ISDKTarget sdkTarget) { // XXX: do
+	 * this better if (sdkTarget == null) return true; return
+	 * sdkTarget.getPlatform
+	 * ().getName().toLowerCase().matches("gregale|bora|chinook|diablo"); }
+	 */
+
+	/** Stop Maemo if it is running. */
+	public void stopMaemo(ISDKTarget sdkTarget) throws MicaException {
+		// maemo processes can still be running...
+		// if (!isXServerStarted(sdkTarget))
+		// throw new
+		// ESboxException("Cannot stop Maemo. Start X Server first");
+
+		MaemoLauncher.getInstance().stopMaemo(sdkTarget);
+	}
+
+	/**
+	 * Start X and Maemo if it is not running.
+	 * <p>
+	 * This kills maemo if X is not running, since maemo may be left hanging is
+	 * X is killed.
+	 */
+	public void startMaemo(ISDKTarget sdkTarget) throws MicaException {
+		if (!XLauncher.getInstance().isXServerStarted(sdkTarget)) {
+			MaemoLauncher.getInstance().killMaemo(sdkTarget);
+		}
+		XLauncher.getInstance().startXIfNeeded(sdkTarget);
+		if (XLauncher.getInstance().isXServerStarted(sdkTarget)) {
+			MaemoLauncher.getInstance().startMaemo(sdkTarget);
+		}
+	}
+
+	/**
+	 * Restart X and Maemo if it is running.
+	 * <p>
+	 * This kills maemo if X is not running, since maemo may be left hanging is
+	 * X is killed.
+	 */
+	public void restartMaemo(ISDKTarget sdkTarget) throws MicaException {
+		if (!XLauncher.getInstance().isXServerStarted(sdkTarget)) {
+			MaemoLauncher.getInstance().killMaemo(sdkTarget);
+		}
+		XLauncher.getInstance().startXIfNeeded(sdkTarget);
+
+		if (XLauncher.getInstance().isXServerStarted(sdkTarget)) {
+			MaemoLauncher.getInstance().restartMaemo(sdkTarget);
+		}
+	}
+
+	/**
+	 * Kill maemo. Does not kill X.
+	 */
+	public void killMaemo(ISDKTarget target) throws MicaException {
+		MaemoLauncher.getInstance().killMaemo(target);
+	}
+
+	/**
+	 * Make sure the build machine associated with the project is alive. This
+	 * must be called from the UI thread or some other top-level caller, since
+	 * it can deadlock.
+	 * 
+	 * @param project
+	 * @param monitor
+	 */
+	public void ensureBuildMachine(IProject project, IProgressMonitor monitor)
+			throws MicaException {
+		if (monitor == null)
+			monitor = new NullProgressMonitor();
+		ISDK sdk = ProjectManager.getInstance().getSDK(project);
+		if (sdk == null)
+			throw new MicaException("Invalid SDK for project: " + project);
+		IMachine machine = sdk.getMachine();
+		IStatus status = MachineManager.getInstance().acquireMachine(machine,
+				monitor);
+		if (!status.isOK())
+			throw new MicaException(status.getMessage(), status.getException());
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,299 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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 (UFCG) - initial implementation
+ *    Ed Swartz (Nokia) - adaptation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core.tools;
+
+import java.net.Socket;
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.console.MessageConsole;
+import org.maemo.mica.common.core.*;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.IPreferenceProvider;
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+
+/**
+ * This class maintains knowledge about whether the X server is running in the
+ * host, and controls access to starting, stopping, and querying status.
+ * 
+ * @author eswartz
+ * 
+ */
+public class XLauncher {
+
+	private static XLauncher instance;
+
+	private Job launchingXJob;
+
+	public synchronized static XLauncher getInstance() {
+		if (instance == null) {
+			instance = new XLauncher();
+		}
+		return instance;
+	}
+
+	/**
+	 * Test a connection to the X server denoted by 'display'. This performs an
+	 * immediate check and is ignorant if a launch is in progress.
+	 * 
+	 * @param display
+	 *            the DISPLAY value, e.g. ":2" or ":0.0" or "myhost:0"
+	 * @return true if connection succeeded
+	 * @throws MicaException
+	 *             if query is impossible
+	 */
+	private boolean testXConnection(String display) throws MicaException {
+		String[] parts = display.split(":");
+		if (parts.length != 2)
+			throw new MicaException(
+					MessageFormat
+							.format(
+									"DISPLAY variable ''{0}'' does not have expected syntax [host]:<number>[.<number>]",
+									display));
+		String host = parts[0];
+		if (host.equals("unix")) {
+			Activator
+					.getErrorLogger()
+					.logError(
+							MessageFormat
+									.format(
+											"Support for testing X connection over UNIX domain sockets is not implemented; assuming success (DISPLAY=''{0}'')",
+											display), null);
+			return true;
+		}
+
+		if (host.length() == 0) {
+			host = null;
+		}
+
+		String[] displayParts = parts[1].split("\\.");
+		int displayNumber = 0;
+		try {
+			displayNumber = Integer.parseInt(displayParts[0]);
+		} catch (NumberFormatException e) {
+			throw new MicaException(
+					MessageFormat
+							.format(
+									"DISPLAY variable ''{0}'' does not have expected syntax [host]:<number>[.<number>]",
+									display));
+		}
+
+		try {
+			/* Socket socket = */new Socket(host, 6000 + displayNumber);
+			return true;
+		} catch (Exception e) {
+			return false;
+		}
+	}
+
+	/**
+	 * Test whether the X server is started by testing a connection to the
+	 * server.
+	 * 
+	 * @param prefProvider
+	 * @return
+	 */
+	public boolean isXServerStarted(IPreferenceProvider prefProvider)
+			throws MicaException {
+		return testXConnection(getDisplayValue(prefProvider));
+	}
+
+	/** Be nice and start X if needed before starting/restarting maemo */
+	public void startXIfNeeded(IPreferenceProvider prefProvider)
+			throws MicaException {
+		waitForXLaunch();
+		if (!isXServerStarted(prefProvider)) {
+			startX(prefProvider);
+			waitForXLaunch();
+		}
+	}
+
+	/**
+	 * Wait forever for the X launching job (if any) to complete. This returns
+	 * only when the job is complete. It does not reflect a successful launch of
+	 * the server.
+	 */
+	private void waitForXLaunch() {
+		while (true) {
+			synchronized (this) {
+				if (launchingXJob == null) {
+					return;
+				}
+				if (launchingXJob != null) {
+					if (launchingXJob.getResult() != null) {
+						return;
+					}
+				}
+			}
+
+			try {
+				Thread.sleep(500);
+			} catch (InterruptedException e) {
+				return;
+			}
+		}
+	}
+
+	public void startX(final IPreferenceProvider prefProvider)
+			throws MicaException {
+		waitForXLaunch();
+
+		if (isXServerStarted(prefProvider))
+			throw new MicaException("X Server is already running");
+
+		String viewer = getDisplayXServerCommand(prefProvider);
+		final String display = getDisplayValue(prefProvider);
+
+		List<String> cmdLine = CommandLineArguments
+				.createFromCommandLine(viewer);
+
+		if (cmdLine.size() > 0) {
+
+			IMachine localMachine = MachineRegistry.getInstance()
+					.getLocalMachine();
+			if (localMachine == null)
+				throw new MicaException("Cannot find local machine");
+
+			IProcessLauncherFactory factory = localMachine.getProcessLauncherFactory();
+			IEnvironmentModifierBlock envBlock = null;
+			
+			String path = prefProvider.getPreferenceValue(MaemoPreferenceConstants.X_PATH);
+			if (path != null && path.length() > 0) {
+				envBlock = ProcessLauncherUtils.addToPATH(localMachine, factory, path, true); 
+			}
+
+			// launch command
+			IProcessLauncher processLauncher = ProcessLauncherCreator.createProcessLauncher(factory, 
+					null,
+					cmdLine,
+					envBlock);
+			
+			final Process process = processLauncher.createProcess();
+
+			final MessageConsole console = processLauncher.redirectToConsole(
+					true, null, "Starting X Server");
+
+			synchronized (this) {
+				launchingXJob = new Job("Waiting for X Server") {
+
+					@Override
+					protected IStatus run(IProgressMonitor monitor) {
+						while (true) {
+							try {
+								if (testXConnection(display))
+									break;
+							} catch (MicaException e) {
+								return Activator.createErrorStatus(
+										"Failed to check X connection", e);
+							}
+
+							try {
+								Thread.sleep(500);
+							} catch (InterruptedException e) {
+								return Policy.getCancelStatus(Activator
+										.getDefault());
+							}
+
+							try {
+								// see if the process terminated yet
+								int exit = process.exitValue();
+
+								console.newMessageStream().println(
+										"Process exited with code 0x"
+												+ Integer.toHexString(exit));
+
+								// report failure outside this job else we can
+								// get stuck here
+								// if someone queries the job status from the UI
+								// thread
+								Display.getDefault().asyncExec(new Runnable() {
+
+									public void run() {
+										Activator
+												.getErrorLogger()
+												.logAndShowError(
+														"X server did not launch; check the Console.",
+														null);
+									}
+
+								});
+								break;
+							} catch (IllegalThreadStateException e) {
+								// not finished, good
+							}
+						}
+						synchronized (XLauncher.this) {
+							launchingXJob = null;
+						}
+						return Status.OK_STATUS;
+					}
+				};
+				launchingXJob.schedule();
+			}
+		} else {
+			Activator.getErrorLogger().logAndShowError(
+					"No X server configured in ESbox preferences", null);
+		}
+
+	}
+
+	public void stopX(IPreferenceProvider prefProvider) throws MicaException {
+		waitForXLaunch();
+
+		if (!isXServerStarted(prefProvider))
+			throw new MicaException(
+					"X Server was not started. Start X Server first");
+
+		String server = getDisplayXServerCommand(prefProvider);
+
+		List<String> cmdLine = CommandLineArguments
+				.createFromCommandLine(server);
+
+		// find server to kill
+		if (cmdLine.size() > 0) {
+			IMachine localMachine = MachineRegistry.getInstance()
+					.getLocalMachine();
+			if (localMachine == null)
+				throw new MicaException("Cannot find local machine");
+
+			MaemoScriptLauncher.getInstance().killProcess(localMachine,
+					cmdLine.get(0), "X Server");
+		}
+	}
+
+	private String getDisplayXServerCommand(IPreferenceProvider prefProvider) {
+		String command = prefProvider
+				.getPreferenceValue(MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+
+		command = command.replaceAll("\\$\\{DISPLAY\\}",
+				getDisplayValue(prefProvider));
+		return command;
+	}
+	
+	private String getDisplayValue(IPreferenceProvider prefProvider) {
+		String value = prefProvider.getPreferenceValue(MaemoPreferenceConstants.X_DISPLAY);
+		if (value.length() > 0)
+			return value;
+		else
+			return System.getenv("DISPLAY"); // get from system
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/Activator.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/Activator.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/Activator.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,153 @@
+package org.maemo.esbox.internal.maemosdk.core;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.maemo.mica.common.core.ErrorLogger;
+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.maemosdk.core";
+
+	// The shared instance
+	private static Activator plugin;
+
+	private IPreferenceStore preferenceStore;
+	
+	/**
+	 * 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 the preference store for this UI plug-in. This preference store
+	 * is used to hold persistent settings for this plug-in in the context of a
+	 * workbench. Some of these settings will be user controlled, whereas others
+	 * may be internal setting that are never exposed to the user.
+	 * <p>
+	 * If an error occurs reading the preference store, an empty preference
+	 * store is quietly created, initialized with defaults, and returned.
+	 * </p>
+	 * <p>
+	 * <strong>NOTE:</strong> As of Eclipse 3.1 this method is no longer
+	 * referring to the core runtime compatibility layer and so plug-ins relying
+	 * on Plugin#initializeDefaultPreferences will have to access the
+	 * compatibility layer themselves.
+	 * </p>
+	 * 
+	 * @return the preference store
+	 */
+	public IPreferenceStore getPreferenceStore() {
+		// Create the preference store lazily.
+		if (preferenceStore == null) {
+			preferenceStore = new ScopedPreferenceStore(new InstanceScope(),
+					getBundle().getSymbolicName());
+
+		}
+		return preferenceStore;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleProjectProperties.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleProjectProperties.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleProjectProperties.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.maemosdk.core;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.esbox.scratchbox.core.sdk.ScratchboxSDKFacade;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.execEnv.*;
+import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.project.core.IProjectProperties;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+/**
+ * This class retrieves the old-style C/C++ or Python project properties stored
+ * in workspace metadata.
+ * 
+ * @author eswartz
+ * 
+ */
+public class OldStyleProjectProperties implements IProjectProperties {
+	private static final String TARGET_NAME_ID = "org.indt.esbox.project.targetName";
+
+	private static final String SCRATCHBOX_VERSION_ID = "org.indt.esbox.project.scratchboxVersion";
+
+	private static final String EXECUTION_ENVIRONMENT_ID = "org.indt.esbox.project.execEnv";
+
+	static final QualifiedName targetNameProperty = new QualifiedName(
+			TARGET_NAME_ID, "Scratchbox Target");
+
+	static final QualifiedName scratchboxVersionProperty = new QualifiedName(
+			SCRATCHBOX_VERSION_ID, "Scratchbox Version");
+
+	static final QualifiedName executionEnvironmentProperty = new QualifiedName(
+			EXECUTION_ENVIRONMENT_ID, "Execution Environment");
+
+	private IProject project;
+
+	public OldStyleProjectProperties(IProject project) {
+		this.project = project;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.common.core.IPropertyAccess#read(java.lang.String)
+	 */
+	private String readProperty(QualifiedName property) {
+		try {
+			return project.getPersistentProperty(property);
+		} catch (CoreException e) {
+			Activator.getErrorLogger().logError(
+					"Could not read project property", e);
+			return null;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.common.project.core.IProjectProperties#getExecutionEnvironment()
+	 */
+	public IExecutionEnvironment getExecutionEnvironment() {
+		IExecutionEnvironment execEnv = null;
+		String execEnvId = readProperty(executionEnvironmentProperty);
+		if (execEnvId == null) {
+			// XXX: this is compatibility behavior
+			// execEnvId =
+			// "org.maemo.esbox.scratchbox.core.execution_environment.maemo";
+		}
+		execEnv = ExecutionEnvironmentFactory.getInstance()
+				.findExecutionEnvironment(execEnvId);
+		if (execEnv == null) {
+			execEnv = new UnknownExecutionEnvironment();
+		}
+		return execEnv;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.common.project.core.IProjectProperties#getExecutionEnvironmentId
+	 * ()
+	 */
+	public String getExecutionEnvironmentId() {
+		return readProperty(executionEnvironmentProperty);
+	}
+
+	/**
+	 * Get the SDK target (SDK + target name) for the project's configured SDK
+	 * 
+	 * @return SDK target, never <code>null</code>
+	 * @throws MicaException
+	 *             if no target known
+	 */
+	public ISDKTarget getSDKTarget() throws MicaException {
+		if (!project.isOpen())
+			throw new MicaException(MessageFormat.format(
+					"Project ''{0}'' is not open", project.getName()));
+
+		ISDK sdk = getSDK();
+		String targetName = getTargetName();
+
+		ISDKTarget target = sdk.findSDKTarget(targetName);
+		if (target == null) {
+			throw new MicaException(MessageFormat.format(
+					"Project ''{0}'' references an unavailable target ''{1}''",
+					project.getName(), targetName));
+		}
+
+		return target;
+	}
+
+	/**
+	 * Get the SDK for the project
+	 * 
+	 * @return SDK, never <code>null</code>
+	 * @throws MicaException
+	 *             if no SDK known
+	 */
+	public ISDK getSDK() throws MicaException {
+		ISDK sdk = null;
+
+		String version = readProperty(scratchboxVersionProperty);
+		if (version == null) {
+			// old projects
+			version = "1";
+		}
+
+		List<IScratchboxSDK> sboxSDKs = ScratchboxSDKFacade.getInstance()
+				.getAllScratchboxSDKs();
+		for (IScratchboxSDK sboxSDK : sboxSDKs) {
+			if (version.equals(Integer.toString(sboxSDK.getSboxVersion()))) {
+				sdk = sboxSDK;
+				break;
+			}
+		}
+
+		if (sdk == null) {
+			throw new MicaException(
+					MessageFormat
+							.format(
+									"Project ''{0}'' uses an unsupported scratchbox version {1}",
+									project.getName(), version));
+		}
+
+		return sdk;
+	}
+
+	public synchronized String getTargetName() {
+		return readProperty(targetNameProperty);
+	}
+
+	public synchronized String getSDKName() {
+		String sboxVersion = readProperty(scratchboxVersionProperty);
+	
+		if (sboxVersion == null)
+			return null;
+		
+		List<IScratchboxSDK> sboxSDKs;
+		try {
+			sboxSDKs = ScratchboxSDKFacade.getInstance().getAllScratchboxSDKs();
+		} catch (ScratchboxException e) {
+			return null;
+		}
+		for (IScratchboxSDK sboxSDK : sboxSDKs) {
+			if (sboxVersion.equals(Integer.toString(sboxSDK.getSboxVersion()))) {
+				return sboxSDK.getName();
+			}
+		}
+		return null;
+	}
+
+	// public synchronized String getScratchboxVersion(IProject project) {
+	// return readProperty(scratchboxVersionProperty);
+	// }
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleWorkspaceProjectPropertiesProvider.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleWorkspaceProjectPropertiesProvider.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/OldStyleWorkspaceProjectPropertiesProvider.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.maemosdk.core;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+import org.maemo.mica.common.project.core.IOldStyleProjectPropertiesProvider;
+import org.maemo.mica.common.project.core.IProjectProperties;
+
+/**
+ * Implementation of oldStyleProjectPropertiesProvider to allow converting old
+ * projects to the current format.
+ * 
+ * @author eswartz
+ * 
+ */
+public class OldStyleWorkspaceProjectPropertiesProvider implements
+		IOldStyleProjectPropertiesProvider {
+
+	// NOTE: these nature IDs are stored here to avoid forcing this feature
+	// to depend on C/C++ or Python.
+	private static final String ESBOX_NATURE_ID = "org.indt.esbox.core.ESboxNature";
+	private static final String ESBOX_PYTHON_NATURE_ID = "org.indt.esbox.core.esboxPythonNature";
+
+	private boolean isNatureInProject(IProject _project, String id) {
+		if (_project != null && _project.isOpen()) {
+			try {
+				IProjectNature nature = _project.getNature(id);
+				if (nature != null) {
+					return true;
+				}
+			} catch (CoreException e) {
+				Activator.getErrorLogger().logError(
+						"Cannot detect project nature", e);
+			}
+		}
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.project.core.IOldStyleProjectPropertiesProvider#
+	 * createProjectProperties(org.eclipse.core.resources.IProject)
+	 */
+	public IProjectProperties createProjectProperties(IProject project) {
+		if (isNatureInProject(project, ESBOX_NATURE_ID)
+				|| isNatureInProject(project, ESBOX_PYTHON_NATURE_ID))
+			return new OldStyleProjectProperties(project);
+		return null;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentAdapter.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentAdapter.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentAdapter.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.maemosdk.core.adapters;
+
+import org.eclipse.core.resources.IProject;
+import org.maemo.esbox.internal.api.maemosdk.core.execEnv.MaemoExecutionEnvironment;
+import org.maemo.mica.common.core.adapters.IDefaultExecutionEnvironmentAdapter;
+import org.maemo.mica.common.core.execEnv.ExecutionEnvironmentFactory;
+import org.maemo.mica.common.core.execEnv.IExecutionEnvironment;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+
+/**
+ * Implementation of default execution environment adapter
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoDefaultExecutionEnvironmentAdapter implements
+		IDefaultExecutionEnvironmentAdapter {
+	final ISDKTarget sdkTarget;
+
+	public MaemoDefaultExecutionEnvironmentAdapter(ISDKTarget sdkTarget) {
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.core.adapters.IDefaultExecutionEnvironmentAdapter#
+	 * getDefaultExecutionEnvironment(org.eclipse.core.resources.IProject)
+	 */
+	public IExecutionEnvironment getDefaultExecutionEnvironment(IProject project) {
+		// TODO: more intelligent check
+		return ExecutionEnvironmentFactory.getInstance()
+				.findExecutionEnvironment(MaemoExecutionEnvironment.ID);
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentFactory.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentFactory.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoDefaultExecutionEnvironmentFactory.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.maemosdk.core.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.mica.common.core.adapters.IDefaultExecutionEnvironmentAdapter;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+
+/**
+ * This factory ties "default execution environment" support into an SDK target
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoDefaultExecutionEnvironmentFactory implements IAdapterFactory {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
+	 * java.lang.Class)
+	 */
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(IDefaultExecutionEnvironmentAdapter.class)) {
+			if (adaptableObject instanceof ISDKTarget) {
+				ISDKTarget sdkTarget = (ISDKTarget) adaptableObject;
+				return new MaemoDefaultExecutionEnvironmentAdapter(sdkTarget);
+			}
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	public Class[] getAdapterList() {
+		return new Class[] { IDefaultExecutionEnvironmentAdapter.class };
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapter.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapter.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapter.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.maemosdk.core.adapters;
+
+import org.maemo.esbox.internal.api.maemosdk.core.MaemoEnvironmentUtils;
+import org.maemo.mica.common.core.env.EnvironmentManager;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.launch.adapters.ITargetEnvironmentModifierAdapter;
+import org.maemo.mica.common.launch.core.AbstractLocalLaunchProxy;
+import org.maemo.mica.common.launch.core.ILaunchProxy;
+
+/**
+ * Provide the necessary variables for maemo launches.
+ * @author eswartz
+ *
+ */
+public class MaemoTargetEnvironmentModifierAdapter implements ITargetEnvironmentModifierAdapter {
+
+	private final ISDKTarget sdkTarget;
+
+	/**
+	 * @param sdkTarget
+	 */
+	public MaemoTargetEnvironmentModifierAdapter(ISDKTarget sdkTarget) {
+		this.sdkTarget = sdkTarget;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.maemo.mica.common.launch.adapters.ITargetEnvironmentModifierAdapter#getTargetEnvironmentModifierBlock(org.maemo.mica.common.launch.core.ILaunchProxy)
+	 */
+	public IEnvironmentModifierBlock getTargetEnvironmentModifierBlock(ILaunchProxy launchProxy) {
+		IEnvironmentModifierBlock envBlock = EnvironmentManager.getInstance().createEnvironmentModifierBlock();
+		
+		// first, all launches need proper DBUS access
+		envBlock.define("DBUS_SESSION_BUS_ADDRESS", "unix:path=/tmp/session_bus_socket");
+		
+		if (launchProxy instanceof AbstractLocalLaunchProxy) {
+			MaemoEnvironmentUtils.defineEmulatorXDisplayVariable(sdkTarget.getSDK().getMachine(), envBlock);
+			
+		} else {
+			// remote launches need DISPLAY for its own machine
+			
+			envBlock.define("DISPLAY", ":0");
+			
+		}
+		
+		return envBlock;
+	}
+
+}
+

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapterFactory.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapterFactory.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/maemosdk/core/adapters/MaemoTargetEnvironmentModifierAdapterFactory.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.maemosdk.core.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.launch.adapters.ITargetEnvironmentModifierAdapter;
+
+/**
+ * 
+ * @author eswartz
+ *
+ */
+public class MaemoTargetEnvironmentModifierAdapterFactory implements IAdapterFactory {
+
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+	 */
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(ITargetEnvironmentModifierAdapter.class)) {
+			if (adaptableObject instanceof ISDKTarget) {
+				ISDKTarget sdkTarget = (ISDKTarget) adaptableObject;
+				return new MaemoTargetEnvironmentModifierAdapter(sdkTarget);
+			}
+		}
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	public Class[] getAdapterList() {
+		return new Class[] { ITargetEnvironmentModifierAdapter.class };
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk/core/MaemoPreferenceConstants.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk/core/MaemoPreferenceConstants.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/maemosdk/core/MaemoPreferenceConstants.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.maemosdk.core;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.internal.api.maemosdk.core.MaemoPreferenceConstantsPrivate;
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+
+/**
+ * This class encapsulates the keys for preference constants defined by the
+ * Maemo plugins.
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoPreferenceConstants {
+	public static final int VERSION_MAJOR = 17;
+	public static final int VERSION_MINOR = 0;
+
+	/** Get the preference store that contains these preferences */
+	public static IPreferenceStore getPreferenceStore() {
+		return Activator.getDefault().getPreferenceStore();
+	}
+
+	/* X/Maemo actions */
+	public static final String DISPLAY_X_COMMAND = "DISPLAY_X_COMMAND";
+	public static final String GAZPACHO_COMMAND = "GAZPACHO_COMMAND";
+	public static final String MAEMO_COMMAND = "MAEMO_COMMAND";
+	public static final String MAEMO_START_ACTION = "MAEMO_START_ACTION";
+	public static final String MAEMO_STOP_ACTION = "MAEMO_STOP_ACTION";
+	public static final String MAEMO_RESTART_ACTION = "MAEMO_RESTART_ACTION";
+	public static final String USE_X_HOST = "USE_X_HOST";
+	public static final String X_HOST_CMD = "X_HOST_CMD";
+	public static final String X_DISPLAY = "X_DISPLAY";
+	public static final String X_PATH = "X_PATH";
+	
+	static final Class privateKeysClass = MaemoPreferenceConstantsPrivate.class;
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.classpath
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.classpath	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.classpath	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.project
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.project	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/.project	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.maemo.esbox.scratchbox.sb1</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/META-INF/MANIFEST.MF
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/META-INF/MANIFEST.MF	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/META-INF/MANIFEST.MF	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ESbox Scratchbox 1 Support
+Bundle-SymbolicName: org.maemo.esbox.scratchbox.sb1;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.maemo.esbox.internal.scratchbox.sb1.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.maemo.mica.maemosdk.core;bundle-version="2.0.0";visibility:=reexport,
+ org.eclipse.ui.ide,
+ org.maemo.mica.maemosdk.ui;bundle-version="2.0.0",
+ org.maemo.esbox.scratchbox.core;bundle-version="2.0.0",
+ org.maemo.esbox.scratchbox.ui;bundle-version="2.0.0",
+ org.maemo.esbox.maemosdk.core;bundle-version="2.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: INdT / Nokia
+Export-Package: org.maemo.esbox.internal.scratchbox.sb1.command;x-friends:="org.maemo.esbox.scratchbox.tests",
+ org.maemo.esbox.internal.scratchbox.sb1.core;x-friends:="org.maemo.esbox.scratchbox.tests",
+ org.maemo.esbox.internal.scratchbox.sb1.provider;x-friends:="org.maemo.esbox.scratchbox.tests",
+ org.maemo.esbox.scratchbox.sb1.sdk

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/build.properties
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/build.properties	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/build.properties	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               conf/

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/run.sh
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/run.sh	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/run.sh	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#/*******************************************************************************
+# * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia.
+# * 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 (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+# *    Ed Swartz (Nokia) - additions and changes
+# *******************************************************************************/
+
+__version=0.5
+__release=1.2
+__location=$1
+__export_list=$2
+shift
+shift
+__command="$@"
+
+if [ ! -d $__location ] ; then
+        echo "E: Directory $__location not found"
+        exit 1
+fi
+
+cd $__location
+
+# apply exports and unsets
+if [ "$__export_list" != "-" ] ; then
+	IFS=,; for __export in $__export_list; do
+		case $__export in 
+			-* ) 	unset `echo $__export | sed s/-//` ;;
+			* ) 	export $__export ;;
+		esac
+	done
+	IFS=" "
+fi
+
+# Run command
+$__command
+

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/sb1_prefs.xml
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/sb1_prefs.xml	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/conf/sb1_prefs.xml	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+
+<properties>
+	<comment>This file contains the default settings for Scratchbox 1 preferences; 
+	see the org.maemo.mica.common.core.preference_set_provider extension</comment>
+
+	<!-- WHEN ANY DEFAULTS CHANGED warranting rewriting prefs, 
+		bump pref version in esbox_common.xml and adjust ESboxPreferenceInitializer#RPEFS_VERSION_MAJOR ;
+		WHEN ANYTHING ELSE CHANGED which can be merged into existing prefs, 
+		adjust ESboxPreferenceInitializer#RPEFS_VERSION_MINOR -->
+		
+	<entry key="SB1_LOGIN_COMMAND">/scratchbox/login -d ${RUN_SCRIPT_DIRECTORY} "./${RUN_SCRIPT} ${{DIRECTORY}} \\\"${{{EXPORTS}}}\\\" \\\"${{{COMMAND}}} ${{{ARGS}}}\\\""</entry>
+	<entry key="SB1_SBOX_COMMAND">sb-conf ${ACTIONS} ${OPTIONS}</entry>	
+
+	<entry key="RUN_SCRIPT_LOC">/scratchbox/users/${USER}/home/${USER}/.esbox/</entry>
+
+	<!-- this uses ${QEMU} because the default qemu-arm is an often misconfigured softlink: see GetGdbQemuCommandPatternCommand -->
+	<entry key="SB1_GDB_REMOTE_QEMU">${QEMU} -g ${PORT}</entry>
+	
+	<!-- actions of command sb-conf  -->	
+	
+	<entry key="SB1_VERSION_ACT">version</entry>
+	<entry key="SB1_SETUP_ACT">setup</entry>
+	<entry key="SB1_INSTALL_ACT">install</entry>	
+	<entry key="SB1_ROOTSTRAP_ACT">rootstrap</entry>
+	<entry key="SB1_SELECT_ACT">select</entry>
+	<entry key="SB1_RESET_ACT">reset</entry>
+	<entry key="SB1_KILLALL_ACT">killall</entry>
+	<entry key="SB1_REMOVE_ACT">remove</entry>
+	<entry key="SB1_SHOW_ACT">show</entry>
+	<entry key="SB1_LIST_ACT">list</entry>
+	<entry key="SB1_CURRENT_ACT">current</entry>
+	
+	<!-- options for action rootstrap -->
+	<entry key="SB1_ROOTSTRAP_OPT_FORCE">--force</entry>
+	<entry key="SB1_SETUP_ACT">setup</entry>
+	
+	<!-- options for action remove -->
+	<entry key="SB1_REMOVE_OPT_FORCE">--force</entry>
+	
+	<!-- options for action setup -->
+	<entry key="SB1_SETUP_OPT_COMPILER">--compiler=${COMPILER}</entry>
+	<entry key="SB1_SETUP_OPT_DEVKITS">--devkits=${LIST}</entry>
+	<entry key="SB1_SETUP_OPT_CPUTRANSP">--cputransp=${METHOD}</entry>
+	<entry key="SB1_SETUP_OPT_FORCE">--force</entry>
+	
+	<!-- options for action killall -->
+	<entry key="SB1_KILLALL_OPT_SIGNAL">signal=${SIGNAL}</entry>	
+	
+	<!-- options for action install -->
+	<entry key="SB1_INSTALL_OPT_CLIB">--clibrary</entry>
+	<entry key="SB1_INSTALL_OPT_ETC">--etc</entry>
+	<entry key="SB1_INSTALL_OPT_DEVKITS">--devkits</entry>
+	<entry key="SB1_INSTALL_OPT_FAKE">--fakeroot</entry>
+	<entry key="SB1_INSTALL_OPT_GDB">--gdb</entry>
+	<entry key="SB1_INSTALL_OPT_STRACE">--strace</entry>	
+	
+	<!-- options for action show -->
+	<entry key="SB1_SHOW_OPT_COMPILERS">--compilers</entry>
+	<entry key="SB1_SHOW_OPT_DEVKITS">--devkits</entry>
+	<entry key="SB1_SHOW_OPT_CPU">--cputransp</entry>
+	<entry key="SB1_SHOW_OPT_COMP_ARCH">--compiler-arch</entry>
+	<entry key="SB1_SHOW_OPT_COMP_SUBARCH">--compiler-subarch</entry>
+	<entry key="SB1_SHOW_OPT_COMP_CLIB">--compiler-clib</entry>
+	
+	<!-- options for action list -->
+	<entry key="SB1_LIST_OPT_COMPILERS">--compilers</entry>
+	<entry key="SB1_LIST_OPT_DEVKITS">--devkits</entry>
+	<entry key="SB1_LIST_OPT_CPU">--cputransps</entry>
+	<entry key="SB1_LIST_OPT_TARGETS">--targets</entry>
+	<entry key="SB1_LIST_OPT_SESSIONS">--sessions</entry>
+	
+	<!-- setting such as Scratchbox location and user name -->
+	<entry key="SB1_SBOX_SANDBOX">/scratchbox/users/${USER}</entry>
+	
+</properties>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/plugin.xml
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/plugin.xml	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/plugin.xml	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension
+         point="org.maemo.mica.common.core.sdk_provider">
+      <sdk_provider
+            class="org.maemo.esbox.internal.scratchbox.sb1.provider.Scratchbox1SDKProvider">
+      </sdk_provider>
+   </extension>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            category="org.maemo.mica.common.ui.preferenceCategory.maemo"
+            class="org.maemo.esbox.internal.scratchbox.sb1.ui.preferences.Scratchbox1PreferencesPage"
+            id="org.maemo.mica.maemosdk.sb1.preferencePage.sb1"
+            name="Scratchbox 1">
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.core.runtime.adapters">
+      <factory
+            adaptableType="org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK"
+            class="org.maemo.esbox.internal.scratchbox.sb1.ui.adapters.MaemoScratchbox1SDKManageTargetAdapterFactory">
+         <adapter
+               type="org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter">
+         </adapter>
+      </factory>
+      <factory
+            adaptableType="org.maemo.mica.common.core.sdk.ISDKTarget"
+            class="org.maemo.esbox.internal.scratchbox.sb1.ui.adapters.Scratchbox1PrepareTargetProcessLaunchAdapterFactory">
+         <adapter
+               type="org.maemo.mica.common.core.adapters.IPrepareTargetProcessLaunchAdapter">
+         </adapter>
+      </factory>
+   </extension>
+   <extension
+         point="org.maemo.mica.common.core.preference_set_provider">
+      <preferenceSetProvider
+            defaultsXMLFile="conf/sb1_prefs.xml"
+            preferenceConstantsClass="org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants"
+            preferenceMigratorClass="org.maemo.mica.internal.api.common.core.OldESboxPreferenceMigrator"
+            preferenceStoreBundle="org.maemo.esbox.scratchbox.sb1"
+            version="17">
+      </preferenceSetProvider>
+   </extension>
+
+</plugin>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,146 @@
+package org.maemo.esbox.internal.scratchbox.sb1;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.maemo.mica.common.core.ErrorLogger;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.maemo.mica.maemosdk.sdk1";
+
+	// The shared instance
+	private static Activator plugin;
+
+	private IPreferenceStore preferenceStore;
+
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugin#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;
+	}
+
+	/**
+	 * 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();
+	}
+
+	/**
+	 * 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);
+	}
+
+	/**
+	 * 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 the preference store for this UI plug-in. This preference store
+	 * is used to hold persistent settings for this plug-in in the context of a
+	 * workbench. Some of these settings will be user controlled, whereas others
+	 * may be internal setting that are never exposed to the user.
+	 * <p>
+	 * If an error occurs reading the preference store, an empty preference
+	 * store is quietly created, initialized with defaults, and returned.
+	 * </p>
+	 * <p>
+	 * <strong>NOTE:</strong> As of Eclipse 3.1 this method is no longer
+	 * referring to the core runtime compatibility layer and so plug-ins relying
+	 * on Plugin#initializeDefaultPreferences will have to access the
+	 * compatibility layer themselves.
+	 * </p>
+	 * 
+	 * @return the preference store
+	 */
+	public IPreferenceStore getPreferenceStore() {
+		// Create the preference store lazily.
+		if (preferenceStore == null) {
+			preferenceStore = new ScopedPreferenceStore(new InstanceScope(),
+					getBundle().getSymbolicName());
+
+		}
+		return preferenceStore;
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/AbstractSB1Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/AbstractSB1Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/AbstractSB1Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import java.security.InvalidParameterException;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.AbstractSDKCommand;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+/**
+ * @author baranov
+ * 
+ */
+public abstract class AbstractSB1Command extends AbstractSDKCommand {
+
+	/**
+	 * @param commandAbstractor
+	 */
+	public AbstractSB1Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		// TODO Auto-generated constructor stub
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.command.AbstractSDKCommand#
+	 * replaceScratchboxConfigCommand(java.lang.String, java.lang.String[])
+	 */
+	public String replaceScratchboxConfigCommand(String action, String[] options)
+			throws InvalidParameterException {
+		String sboxCommand;
+
+		sboxCommand = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SBOX_COMMAND);
+
+		return replaceScratchboxCommand(sboxCommand, action, options);
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/CreateTargetCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/CreateTargetCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/CreateTargetCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Creates a new target, if it does not exist. This command wraps the callback
+ * to service sb-conf setup [<TARGET>] [--compiler=<COMPILER>]
+ * [--devkits=<LIST>] [--cputransp=<METHOD>] [--force]
+ * 
+ */
+public class CreateTargetCommand extends AbstractSB1Command {
+
+	private IScratchbox1SDK sdk;
+
+	public CreateTargetCommand(IScratchbox1SDK sdk,
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param) throws MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String compilerName = param.get(1);
+		String devkitsNames = param.get(2);
+		String cputranspName = param.get(3);
+
+		String setupTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_ACT);
+
+		String[] setupActionOptionsReplaced = this.replaceActions(targetName,
+				compilerName, devkitsNames, cputranspName);
+		String setupTargetCommand = this.replaceScratchboxConfigCommand(
+				setupTargetAction, setupActionOptionsReplaced);
+
+		Process process = createProcess(setupTargetCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	/**
+	 * Replace the options of action SETUP. The options of SETUP action are
+	 * different from the other ones, so this method replaces the variables
+	 * properly.
+	 * 
+	 * @param targetName
+	 *            the name of the target.
+	 * 
+	 * @param compiler
+	 *            the compiler name of the target.
+	 * @param devkits
+	 *            the devkits of the target.
+	 * @param cputransp
+	 *            the cputransp method of the target.
+	 * @return an array of String with the options already modified with the
+	 *         options.
+	 */
+	protected String[] replaceActions(String targetName, String compiler,
+			String devkits, String cputransp) {
+		String[] setupActions = new String[4];
+		setupActions[0] = targetName;
+		setupActions[1] = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_OPT_COMPILER);
+		setupActions[2] = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_OPT_DEVKITS);
+		setupActions[3] = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_OPT_CPUTRANSP);
+
+		setupActions[1] = setupActions[1].replaceAll("\\$\\{COMPILER\\}",
+				compiler);
+		setupActions[2] = setupActions[2].replaceAll("\\$\\{LIST\\}", devkits);
+		setupActions[3] = setupActions[3].replaceAll("\\$\\{METHOD\\}",
+				cputransp);
+
+		return setupActions;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 4;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Get the current Scratchbox 1 target. This command wraps the callback to
+ * service sb-conf current
+ */
+public class GetCurrentTargetCommand extends AbstractSB1Command {
+
+	private final IScratchbox1SDK sdk;
+
+	public GetCurrentTargetCommand(ICommandAbstractor commandAbstractor,
+			IScratchbox1SDK sdk) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		if (sdk.getCachedCurrentTarget() != null)
+			return sdk.getCachedCurrentTarget();
+
+		String currentTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_CURRENT_ACT);
+		String currentTargetCommand = this
+				.replaceScratchboxConfigCommand(currentTargetAction);
+
+		Process process = createProcess(currentTargetCommand, null);
+
+		String currentTarget = getInputFromProcessAndWait(process, true, 0);
+
+		sdk.setCachedCurrentTarget(currentTarget);
+		return currentTarget;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetGdbQemuCommandPatternCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetGdbQemuCommandPatternCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetGdbQemuCommandPatternCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.eclipse.core.runtime.IStatus;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.SBPreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+import org.osgi.framework.Version;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Get the command pattern for launching qemu with the debugger
+ * 
+ * @author eswartz
+ * 
+ */
+public class GetGdbQemuCommandPatternCommand extends AbstractSB1Command {
+
+	private IScratchboxSDKTarget sdkTarget;
+
+	public GetGdbQemuCommandPatternCommand(IScratchboxSDKTarget sdkTarget,
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String commandPattern = null;
+
+		String architecture = param.get(0);
+
+		if (architecture.equals(IScratchboxSDKTarget.ARCHITECTURE_ARMEL)) {
+			// scratchbox often misconfigures the softlinks, so explicitly
+			// launch the qemu configured for the target
+			String qemu = getConfiguredQemu();
+			if (qemu == null) {
+				// fallback
+				Activator
+						.getErrorLogger()
+						.log(
+								IStatus.WARNING,
+								"Target "
+										+ sdkTarget
+										+ " does not seem to use qemu, so assuming qemu-arm for debugging",
+								null);
+				qemu = "qemu-arm";
+			}
+			// get the version
+			Version version = null;
+			Pattern versionPattern = Pattern
+					.compile("qemu-.*((\\d+)\\.(\\d+)\\.(\\d+))-.*");
+			Matcher matcher = versionPattern.matcher(qemu);
+			if (matcher.matches()) {
+				version = new Version(matcher.group(1));
+			}
+
+			// For ARM emulator debug, use "qemu-arm" command.
+			commandPattern = sdkTarget
+					.getPreferenceValue(SB1PreferenceConstants.SB1_GDB_REMOTE_QEMU);
+
+			if (version != null && version.compareTo(new Version(0, 8, 0)) < 0) {
+				// hide ${PORT}, which doesn't exist in 0.7.x
+				commandPattern = commandPattern.replace("${PORT}", "");
+				// Activator.getErrorLogger().log(IStatus.WARNING,
+				// "The version of qemu-arm in use (" + version +
+				// ") is too old -- debugging may not work.  Check your softlinks in /scratchbox/devkits/cputransp/bin/.",
+				// null);
+			}
+
+			commandPattern = commandPattern.replace("${QEMU}", qemu);
+
+		} else {
+			// The others, just standard "gdbserver" command.
+			commandPattern = sdkTarget
+					.getPreferenceValue(SBPreferenceConstants.SBOX_GDB_REMOTE);
+		}
+
+		return commandPattern;
+	}
+
+	/**
+	 * Find what qemu is configured for this target.
+	 * 
+	 * @return qemu name, or <code>null</code> if not using qemu
+	 */
+	protected String getConfiguredQemu() throws MicaException {
+
+		// we use sb-select show <target> to find out if qemu is even used for
+		// this target.
+		String showAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SHOW_ACT);
+		String showInfoCommandString = this.replaceScratchboxConfigCommand(
+				showAction, new String[] { sdkTarget.getName() });
+
+		Process process = createProcess(showInfoCommandString, null);
+
+		List<String> lines = getLineInputFromProcessAndWait(process, true, 0);
+
+		// see if this is the line describing CPU transparency
+		Pattern namePattern = Pattern.compile(".*/(qemu-\\S+).*");
+		for (String line : lines) {
+			Matcher matcher = namePattern.matcher(line);
+			if (matcher.matches()) {
+				return matcher.group(1);
+			}
+		}
+
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 1;
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetVersionScratchboxCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetVersionScratchboxCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetVersionScratchboxCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Get the version of Scratchbox installed. This command wraps the callback to
+ * service sb-conf version.
+ * 
+ */
+public class GetVersionScratchboxCommand extends AbstractSB1Command {
+
+	public GetVersionScratchboxCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.ScratchboxCommand#getParametersSize()
+	 */
+	public int getParametersSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .util.List)
+	 */
+	public String performCommand(List<String> params)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String sboxVersionAction;
+		sboxVersionAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_VERSION_ACT);
+		String currentSboxVersionCommand = this
+				.replaceScratchboxConfigCommand(sboxVersionAction);
+
+		Process process = createProcess(currentSboxVersionCommand, null);
+
+		String currentVersion = getInputFromProcessAndWait(process, false, 0);
+
+		return currentVersion;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/KillallCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/KillallCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/KillallCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Kill all Scratchbox sessions. This command wraps the callback to service
+ * sb-conf killall [-signal=<SIGNAL>]
+ * 
+ */
+public class KillallCommand extends AbstractSB1Command {
+
+	public KillallCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String signalValue = "";
+		if (param.size() > 0)
+			signalValue = param.get(0);
+
+		String killallAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_KILLALL_ACT);
+		String signalOption = this.replaceSignal(signalValue);
+		String killallCommand = this.replaceScratchboxConfigCommand(
+				killallAction, new String[] { signalOption });
+
+		Process process = createProcess(killallCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		return true;
+	}
+
+	/**
+	 * Replace the value of SIGNAL option of killall action.
+	 * 
+	 * @param signalValue
+	 *            the value of the signal to be replaced.
+	 * @return the signal option of killall action replaced with the given
+	 *         signal value.
+	 */
+	private String replaceSignal(String signalValue) {
+		if (signalValue.equals(""))
+			return "";
+		String killallSignalOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_KILLALL_OPT_SIGNAL);
+
+		String signalReplaced = killallSignalOption.replaceAll(
+				"\\$\\{SIGNAL\\}", signalValue);
+
+		return signalReplaced;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 1;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.command.ScratchboxCommand#checkParameters
+	 * (java.util.List)
+	 */
+	protected boolean checkParameters(List<String> param) {
+		// TODO Auto-generated method stub
+		return getParametersSize() <= 1;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCompilersCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCompilersCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCompilersCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * List the installed compilers. This command wraps the callback to service
+ * sb-conf list --compilers
+ * 
+ */
+public class ListCompilersCommand extends AbstractSB1Command {
+
+	public ListCompilersCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String compilersOptions = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_COMPILERS);
+		String listCompilersCommand = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { compilersOptions });
+
+		Process process = createProcess(listCompilersCommand, null);
+
+		List<String> compilersAvailable = getLineInputFromProcessAndWait(
+				process, true, 0);
+
+		return compilersAvailable;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCputranspCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCputranspCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListCputranspCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * List the installed cpu-transparency. This command wraps the callback to
+ * service sb-conf list --cputransps
+ * 
+ */
+public class ListCputranspCommand extends AbstractSB1Command {
+
+	public ListCputranspCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String cputranpOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_CPU);
+		String listCputranspsCommandString = this
+				.replaceScratchboxConfigCommand(listAction,
+						new String[] { cputranpOption });
+
+		Process process = createProcess(listCputranspsCommandString, null);
+
+		List<String> cputranspsAvailable = getLineInputFromProcessAndWait(
+				process, true, 0);
+
+		return cputranspsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListDevkitsCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListDevkitsCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListDevkitsCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * List the installed devkits. This command wraps the callback to service
+ * sb-conf list --devkits
+ * 
+ */
+public class ListDevkitsCommand extends AbstractSB1Command {
+
+	public ListDevkitsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String devkitsOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_DEVKITS);
+		String listDevkitsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { devkitsOption });
+
+		Process process = createProcess(listDevkitsCommandString, null);
+
+		List<String> devkitsAvailable = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		return devkitsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListSessionsCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListSessionsCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListSessionsCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * List the current Scratchbox sessions. This command wraps the callback to
+ * service sb-conf list --sessions
+ * 
+ */
+public class ListSessionsCommand extends AbstractSB1Command {
+
+	public ListSessionsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String sessionsOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_SESSIONS);
+		String listSessionsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { sessionsOption });
+
+		Process process = createProcess(listSessionsCommandString, null);
+
+		List<String> sessionLines = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		List<String> sessionsAvailable = new ArrayList<String>();
+
+		// remove prefix text
+		for (String line : sessionLines) {
+			int idx = line.indexOf(':');
+			if (idx >= 0) {
+				String[] pids = line.substring(idx + 1).split("\\s+");
+				for (String pid : pids) {
+					pid = pid.trim();
+					if (pid.length() > 0)
+						sessionsAvailable.add(pid);
+				}
+			}
+		}
+
+		return sessionsAvailable;
+	}
+
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListTargetsCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListTargetsCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ListTargetsCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * List the installed targets. This command wraps the callback to service (sb1)
+ * sb-conf list --targets or sb2-config -l (sb2)
+ * 
+ */
+public class ListTargetsCommand extends AbstractSB1Command {
+
+	public ListTargetsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction;
+		String targetsOption;
+		listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		targetsOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_TARGETS);
+		String listTargetsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { targetsOption });
+
+		Process process = createProcess(listTargetsCommandString, null);
+
+		List<String> targetsAvailable = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		return targetsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RemoveTargetCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RemoveTargetCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RemoveTargetCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Remove a Scratchbox target. This command wraps the callback to service
+ * sb-conf remove [<TARGET>]
+ * 
+ */
+public class RemoveTargetCommand extends AbstractSB1Command {
+
+	private ISDK sdk;
+
+	public RemoveTargetCommand(ISDK sdk, ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetToRemove = param.get(0);
+		if (!targetExist(targetToRemove))
+			throw new ScratchboxInvalidParameterException("Target "
+					+ targetToRemove + " does not exist.");
+
+		String removeTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_REMOVE_ACT);
+		String forceRemoveTargetOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_REMOVE_OPT_FORCE);
+		String removeTargetCommand = this.replaceScratchboxConfigCommand(
+				removeTargetAction, new String[] { targetToRemove,
+						forceRemoveTargetOption });
+
+		Process process = createProcess(removeTargetCommand, null);
+
+		getInputFromProcessAndWait(process, true, 0);
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	/**
+	 * Verify if a target exists.
+	 * 
+	 * @param targetToRemove
+	 *            the target to verify.
+	 * 
+	 * @return true, if the target exists in Scratchbox; false, otherwise.
+	 * @throws ScratchboxException
+	 *             if some problem occurrs while requesting Scratchbox services.
+	 */
+	private boolean targetExist(String targetToRemove) throws MicaException {
+		List<String> targetsAvailable = new ListTargetsCommand(
+				commandAbstractor).performCommand(new ArrayList<String>());
+		return targetsAvailable.contains(targetToRemove);
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ResetTargetCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ResetTargetCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ResetTargetCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Reset a Scratchbox target. This command wraps the callback to service sb-conf
+ * reset [<TARGET>]
+ * 
+ */
+public class ResetTargetCommand extends AbstractSB1Command {
+
+	public ResetTargetCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .util.List)
+	 */
+	public Object performCommand(List<String> params)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String resetTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_RESET_ACT);
+		String resetTargetCommand = this.replaceScratchboxConfigCommand(
+				resetTargetAction, new String[] {});
+
+		Process process = createProcess(resetTargetCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RootstrapCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RootstrapCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/RootstrapCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * This command wraps the callback to service sb-conf rootstrap [<TARGET>]
+ * <FILE>|<URL>
+ */
+public class RootstrapCommand extends AbstractSB1Command {
+
+	public RootstrapCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String fileOrURL = param.get(0);
+
+		String rootstrapAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_ROOTSTRAP_ACT);
+		String rootstrapCommand = this.replaceScratchboxConfigCommand(
+				rootstrapAction, new String[] { fileOrURL });
+
+		Process process = createProcess(rootstrapCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/SelectTargetCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/SelectTargetCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/SelectTargetCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Select a Scratchbox target. This command wraps the callback to service
+ * sb-conf select [<TARGET>]
+ * 
+ */
+public class SelectTargetCommand extends AbstractSB1Command {
+
+	private final IScratchboxSDK sdk;
+
+	public SelectTargetCommand(ICommandAbstractor commandAbstractor,
+			IScratchboxSDK sdk) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetToSelect = param.get(0);
+
+		String selectTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SELECT_ACT);
+		String selectTargetCommand = this.replaceScratchboxConfigCommand(
+				selectTargetAction, new String[] { targetToSelect });
+
+		Process process = createProcess(selectTargetCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		sdk.setCachedCurrentTarget(targetToSelect);
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ShowTargetCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ShowTargetCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/ShowTargetCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.command;
+
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxTarget;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.*;
+
+/**
+ * Show the settings of a Scratchbox target. This command wraps the callback to
+ * service sb-conf show [<TARGET>]
+ * 
+ */
+public class ShowTargetCommand extends AbstractSB1Command {
+
+	public ShowTargetCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.common.core.internal.command.ICommand#performCommand(java.util
+	 * .List)
+	 */
+	public ScratchboxTarget performCommand(List<String> params)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SHOW_ACT);
+		String showTargetCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { params.get(0) });
+
+		Process process = createProcess(showTargetCommandString, null);
+
+		ScratchboxTarget target = null;
+		List<String> targetInfo = getLineInputFromProcessAndWait(process,
+				false, 0);
+		target = createTarget(params.get(0), targetInfo);
+
+		return target;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.core.scratchbox.internal.command.ScratchboxCommand#
+	 * getParametersSize()
+	 */
+	@Override
+	public int getParametersSize() {
+		// TODO Auto-generated method stub
+		return 1;
+	}
+
+	private ScratchboxTarget createTarget(String targetName,
+			List<String> targetInfo) {
+		ScratchboxTarget target = new ScratchboxTarget();
+
+		target.setName(targetName);
+
+		String compilerField = targetInfo.get(0);
+		String compiler = compilerField.substring(
+				compilerField.indexOf(":") + 1).trim();
+		target.setCompiler(compiler);
+
+		String devkitsField = targetInfo.get(1);
+		devkitsField = devkitsField.substring(devkitsField.indexOf(":") + 1);
+		StringTokenizer tokens = new StringTokenizer(devkitsField);
+		List<String> devkits = new ArrayList<String>();
+		while (tokens.hasMoreTokens()) {
+			devkits.add(tokens.nextToken());
+		}
+		target.setDevkits(devkits);
+
+		String cputranspField = targetInfo.get(2);
+		String cpuTransp = cputranspField.substring(
+				cputranspField.indexOf(":") + 1).trim();
+		target.setCputransp(cpuTransp);
+
+		return target;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/SB1PreferenceConstants.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/SB1PreferenceConstants.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/SB1PreferenceConstants.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb1.core;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+
+/**
+ * This class encapsulates the keys for preference constants defined by
+ * Scratchbox 1.
+ * 
+ * @author eswartz
+ * 
+ */
+public class SB1PreferenceConstants {
+	public static final int VERSION_MAJOR = 17;
+	public static final int VERSION_MINOR = 0;
+
+	/** Get the preference store that contains these preferences */
+	public static IPreferenceStore getPreferenceStore() {
+		return Activator.getDefault().getPreferenceStore();
+	}
+
+	/* SB1 configuration options */
+
+	public static final String RUN_SCRIPT_LOC = "RUN_SCRIPT_LOC";
+
+	public static final String SB1_GDB_REMOTE_QEMU = "SB1_GDB_REMOTE_QEMU";
+	public static final String SB1_CURRENT_ACT = "SB1_CURRENT_ACT";
+	public static final String SB1_SBOX_COMMAND = "SB1_SBOX_COMMAND";
+	public static final String SB1_REMOVE_ACT = "SB1_REMOVE_ACT";
+	public static final String SB1_REMOVE_OPT_FORCE = "SB1_REMOVE_OPT_FORCE";
+	public static final String SB1_RESET_ACT = "SB1_RESET_ACT";
+	public static final String SB1_ROOTSTRAP_ACT = "SB1_ROOTSTRAP_ACT";
+	public static final String SB1_ROOTSTRAP_OPT_FORCE = "SB1_ROOTSTRAP_OPT_FORCE";
+	public static final String SB1_INSTALL_ACT = "SB1_INSTALL_ACT";
+	public static final String SB1_INSTALL_OPT_CLIB = "SB1_INSTALL_OPT_CLIB";
+	public static final String SB1_INSTALL_OPT_DEVKITS = "SB1_INSTALL_OPT_DEVKITS";
+	public static final String SB1_INSTALL_OPT_ETC = "SB1_INSTALL_OPT_ETC";
+	public static final String SB1_INSTALL_OPT_FAKE = "SB1_INSTALL_OPT_FAKE";
+	public static final String SB1_INSTALL_OPT_GDB = "SB1_INSTALL_OPT_GDB";
+	public static final String SB1_INSTALL_OPT_STRACE = "SB1_INSTALL_OPT_STRACE";
+	public static final String SB1_KILLALL_ACT = "SB1_KILLALL_ACT";
+	public static final String SB1_KILLALL_OPT_SIGNAL = "SB1_KILLALL_OPT_SIGNAL";
+	public static final String SB1_LIST_ACT = "SB1_LIST_ACT";
+	public static final String SB1_LIST_OPT_COMPILERS = "SB1_LIST_OPT_COMPILERS";
+	public static final String SB1_LIST_OPT_CPU = "SB1_LIST_OPT_CPU";
+	public static final String SB1_LIST_OPT_DEVKITS = "SB1_LIST_OPT_DEVKITS";
+	public static final String SB1_LIST_OPT_SESSIONS = "SB1_LIST_OPT_SESSIONS";
+	public static final String SB1_LIST_OPT_TARGETS = "SB1_LIST_OPT_TARGETS";
+	public static final String SB1_LOGIN_COMMAND = "SB1_LOGIN_COMMAND";
+	public static final String SB1_SBOX_SANDBOX = "SB1_SBOX_SANDBOX";
+	public static final String SB1_SELECT_ACT = "SB1_SELECT_ACT";
+	public static final String SB1_SETUP_ACT = "SB1_SETUP_ACT";
+	public static final String SB1_SETUP_OPT_COMPILER = "SB1_SETUP_OPT_COMPILER";
+	public static final String SB1_SETUP_OPT_CPUTRANSP = "SB1_SETUP_OPT_CPUTRANSP";
+	public static final String SB1_SETUP_OPT_DEVKITS = "SB1_SETUP_OPT_DEVKITS";
+	public static final String SB1_SETUP_OPT_FORCE = "SB1_SETUP_OPT_FORCE";
+	public static final String SB1_SHOW_ACT = "SB1_SHOW_ACT";
+	public static final String SB1_SHOW_OPT_COMP_ARCH = "SB1_SHOW_OPT_COMP_ARCH";
+	public static final String SB1_SHOW_OPT_COMP_CLIB = "SB1_SHOW_OPT_COMP_CLIB";
+	public static final String SB1_SHOW_OPT_COMP_SUBARCH = "SB1_SHOW_OPT_COMP_SUBARCH";
+	public static final String SB1_SHOW_OPT_COMPILERS = "SB1_SHOW_OPT_COMPILERS";
+	public static final String SB1_SHOW_OPT_CPU = "SB1_SHOW_OPT_CPU";
+	public static final String SB1_SHOW_OPT_DEVKITS = "SB1_SHOW_OPT_DEVKITS";
+	public static final String SB1_VERSION_ACT = "SB1_VERSION_ACT";
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1FileSystemMapping.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1FileSystemMapping.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1FileSystemMapping.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,70 @@
+/**
+ * (c) 2008 Nokia
+ */
+package org.maemo.esbox.internal.scratchbox.sb1.core;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.mica.internal.api.common.core.machine.FileSystemMapping;
+
+import com.nokia.cpp.internal.api.utils.core.Pair;
+
+/**
+ * Represent the mappings from the machine to a Scratchbox 1 target running on
+ * the machine. This represents the direct mappings with all softlinks resolved
+ * (so, not "/scratchbox/users/user/usr" but
+ * "/scratchbox/users/user/targets/CHINOOK_ARMEL/usr")
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1FileSystemMapping extends FileSystemMapping {
+
+	/**
+	 * Construct with default Linux path canonicalizers and add mappings for
+	 * paths known to be mapped.
+	 * 
+	 * @param targetRoot
+	 * @param target
+	 */
+	public Scratchbox1FileSystemMapping(IPath scratchboxBase, String target,
+			String user) {
+
+		super(FileSystemMapping.getMachineCanonicalizer(true),
+				FileSystemMapping.getMachineCanonicalizer(true));
+
+		List<Pair<IPath, IPath>> mappings = getHostToTargetRootMappings();
+		mappings.clear();
+
+		// directories that are the same for all targets
+		String[] topLevelDirs = { "dev", "home", "host_usr", "proc",
+				"scratchbox", "sys", "targets" };
+
+		IPath sharedBase = scratchboxBase;
+		map(mappings, sharedBase, new Path("/"));
+		for (String topLevelDir : topLevelDirs) {
+			map(mappings, sharedBase.append(topLevelDir), new Path(topLevelDir)
+					.makeAbsolute());
+		}
+
+		// directories that depend on the current target
+		String[] topLevelLinks = { "bin", "boot", "cdrom", "etc", "floppy",
+				"initrd", "lib", "media", "mnt", "opt", "root", "sbin", "srv",
+				"usr", "var" };
+
+		IPath perTargetBase = scratchboxBase.append("targets").append(target);
+		for (String topLevelDir : topLevelLinks) {
+			map(mappings, perTargetBase.append(topLevelDir), new Path(
+					topLevelDir).makeAbsolute());
+		}
+
+		setHostToTargetRootMappings(mappings);
+	}
+
+	private void map(List<Pair<IPath, IPath>> mappings, IPath from, IPath to) {
+		mappings.add(new Pair<IPath, IPath>(from, to));
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,366 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.core;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.internal.api.scratchbox.core.sdk.*;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.internal.scratchbox.sb1.command.*;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineUtils;
+import org.maemo.mica.common.core.sdk.*;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+import org.maemo.mica.internal.api.common.core.sdk.BaseSDKPlatform;
+import org.maemo.mica.maemosdk.core.MaemoSDKEngine;
+import org.maemo.mica.maemosdk.core.MaemoSDKInfo;
+
+import java.util.*;
+
+public class Scratchbox1SDK extends AbstractScratchboxSDK implements
+		IScratchbox1SDK {
+
+	private IPath sdkRoot;
+	/** String for URI of machine where we detected scratchbox 1 */
+	static final String SB1_MACHINE = "sb1_machine";
+	/** String for scratchbox 1 version or <code>null</code> */
+	static final String SB1_VERSION = "sb1_version";
+
+	public Scratchbox1SDK(IMachine machine, String version,
+			IPreferenceProvider prefProvider) {
+		super(machine, version, IScratchbox1SDK.NAME, "sb1_machine",
+				"sb1_version", "sb1_targets", 1);
+		this.sdkRoot = null;
+		this.prefProvider = prefProvider;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.AbstractScratchboxSDK#refresh()
+	 */
+	public void refresh() {
+		super.refresh();
+		try {
+			List<String> targetNames = getTargets();
+			List<ISDKTarget> newTargets = new ArrayList<ISDKTarget>();
+			for (String target : targetNames) {
+				IPath sb1TargetRoot = getSDKRoot()
+						.append("targets").append(target); //$NON-NLS-1$
+				ISDKTarget sdkTarget = new Scratchbox1SDKTarget(this,
+						getPlatform(target), getArchitecture(target), target,
+						sb1TargetRoot);
+				newTargets.add(sdkTarget);
+			}
+			this.targets = newTargets;
+		} catch (MicaException e) {
+			Activator.getErrorLogger().logError("Could not refresh targets", e);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.AbstractScratchboxSDK#getCommandAbstractor
+	 * ()
+	 */
+	public ICommandAbstractor getCommandAbstractor() throws MicaException {
+		return getSb1WrappedAbstractor(super.getCommandAbstractor(), this
+				.getMachine());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#createTarget(java.lang
+	 * .String, java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public boolean createTarget(String targetName, String compiler,
+			String devkits, String cputransp) throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(compiler);
+		params.add(devkits);
+		params.add(cputransp);
+
+		CreateTargetCommand createTargetCommand = new CreateTargetCommand(this,
+				getCommandAbstractor());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+		return (Boolean) createTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getCompilers()
+	 */
+	public List<String> getCompilers() throws MicaException {
+		ListCompilersCommand listCompilersCommand = new ListCompilersCommand(
+				getCommandAbstractor());
+		return listCompilersCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getCputransp()
+	 */
+	public List<String> getCputransp() throws MicaException {
+		ListCputranspCommand listCputranspCommand = new ListCputranspCommand(
+				getCommandAbstractor());
+		return listCputranspCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/**
+	 * Return the current version of Scratchbox 1.
+	 * 
+	 * @param machine
+	 * @return the current version of Scratchbox 1.
+	 * @throws MicaException
+	 *             if any problem related to Scratchbox communication occurs,
+	 *             including no scratchbox 1 detected
+	 */
+	public static String getCurrentSboxVersion(IMachine machine)
+			throws MicaException {
+		// find cached value
+		CacheUtils.getInstance().ensureCurrentMachine(SB1_MACHINE, machine);
+		String version = (String) CacheUtils.getInstance().getCachedValue(
+				SB1_VERSION);
+		if (version != null)
+			return version;
+
+		// do the hard work
+		MachineUtils.acquireMachine(machine);
+		ICommandAbstractor commandAbstractor = MachineUtils
+				.getHostCommandAbstractor(machine);
+		commandAbstractor = getSb1WrappedAbstractor(commandAbstractor, machine);
+		GetVersionScratchboxCommand getVersionCommand = new GetVersionScratchboxCommand(
+				commandAbstractor);
+
+		String currentVersion = getVersionCommand
+				.performCommand(new ArrayList<String>());
+
+		// remember cached value
+		CacheUtils.getInstance().setCachedValue(SB1_VERSION, currentVersion);
+
+		return currentVersion;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getCurrentTarget()
+	 */
+	public String getCurrentTarget() throws MicaException {
+		GetCurrentTargetCommand getCurrentTargetCommand = new GetCurrentTargetCommand(
+				getCommandAbstractor(), this);
+		return (String) getCurrentTargetCommand
+				.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getTargets()
+	 */
+	public List<String> getTargets() throws MicaException {
+		CacheUtils.getInstance().ensureCurrentMachine(SB_MACHINE, this.getMachine());
+
+		String[] targetsArray = (String[]) CacheUtils.getInstance()
+				.getCachedValue(SB_TARGETS);
+		if (targetsArray != null)
+			return Arrays.asList(targetsArray);
+
+		ListTargetsCommand listTargetsCommand = new ListTargetsCommand(
+				getCommandAbstractor());
+		List<String> targets = listTargetsCommand
+				.performCommand(new ArrayList<String>());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS,
+				(String[]) targets.toArray(new String[targets.size()]));
+
+		return targets;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDK#getSDKRoot()
+	 */
+	public IPath getSDKRoot() {
+		if (sdkRoot == null) {
+			String userPath = prefProvider
+					.getPreferenceValue(SB1PreferenceConstants.SB1_SBOX_SANDBOX);
+			sdkRoot = new Path(userPath);
+		}
+		return sdkRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#removeTarget(java.lang
+	 * .String)
+	 */
+	public boolean removeTarget(String targetName) throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+
+		RemoveTargetCommand removeTargetCommand;
+
+		removeTargetCommand = new RemoveTargetCommand(this,
+				getCommandAbstractor());
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+
+		return (Boolean) removeTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.sb1.core.IScratchbox1SDK#getDevkits()
+	 */
+	public List<String> getDevkits() throws MicaException {
+		ListDevkitsCommand listDevkitsCommand = new ListDevkitsCommand(
+				getCommandAbstractor());
+		return listDevkitsCommand.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.sb1.core.IScratchbox1SDK#getSessions()
+	 */
+	public List<String> getSessions() throws MicaException {
+		ListSessionsCommand listSessionsCommand = new ListSessionsCommand(
+				getCommandAbstractor());
+		return listSessionsCommand.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.sb1.core.IScratchbox1SDK#killProcess()
+	 */
+	public boolean killProcess() throws MicaException {
+		List<String> params = new ArrayList<String>();
+		KillallCommand killallCommand = new KillallCommand(
+				getCommandAbstractor());
+		return (Boolean) killallCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.sb1.core.IScratchbox1SDK#killProcess(java.lang
+	 * .String)
+	 */
+	public boolean killProcess(String signal) throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(signal);
+		KillallCommand killallCommand = new KillallCommand(
+				getCommandAbstractor());
+		return (Boolean) killallCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.sb1.core.IScratchbox1SDK#selectTarget(java.lang
+	 * .String)
+	 */
+	public boolean selectTarget(String targetName) throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+
+		SelectTargetCommand selectTargetCommand = new SelectTargetCommand(
+				getCommandAbstractor(), this);
+
+		return (Boolean) selectTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.maemosdk.core.sdk.
+	 * IScratchboxSDKPlatformArchitectureProvider
+	 * #getArchitecture(java.lang.String)
+	 */
+	public String getArchitecture(String target) {
+		// convention says this is the part of the target after the underscore
+		int idx = target.lastIndexOf('_');
+		if (idx > 0)
+			return target.substring(idx + 1).toUpperCase();
+		else
+			return IScratchboxSDKTarget.ARCHITECTURE_UNKNOWN;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.maemosdk.core.sdk.
+	 * IScratchboxSDKPlatformArchitectureProvider#getPlatform(java.lang.String)
+	 */
+	public ISDKPlatform getPlatform(String target) {
+		// convention says this is the part of the target before the underscore,
+		// usually the name of the platform directly, except for aberrant 'SDK'
+		// cases
+		int idx = target.lastIndexOf('_');
+		String platformName = ISDKPlatform.NAME_UNKNOWN;
+		String version = ISDKPlatform.VERSION_UNKNOWN;
+		if (idx >= 1) {
+			String platform = target.substring(0, idx);
+			// the 'SDK' one is a hard nut to crack
+			if (!platform.equalsIgnoreCase("SDK")) {
+				platformName = platform.substring(0, 1).toUpperCase()
+						+ platform.substring(1).toLowerCase();
+
+				List<MaemoSDKInfo> maemoSDKS = MaemoSDKEngine.getInstance()
+						.getMaemoSDKS();
+				for (MaemoSDKInfo info : maemoSDKS) {
+					if (info.getName().equalsIgnoreCase(platformName)) {
+						version = info.getVersion();
+						break;
+					}
+				}
+			} else {
+				// TODO: look at key files or versions to determine the
+				// platform from the SDK target contents
+			}
+		}
+		return new BaseSDKPlatform(platformName, version);
+	}
+
+	/**
+	 * Get a command abstractor that updates the PATH if sb1 tools are not on
+	 * the path.
+	 * 
+	 * @param commandAbstractor
+	 * @param machine
+	 * @return
+	 */
+	private static ICommandAbstractor getSb1WrappedAbstractor(
+			ICommandAbstractor commandAbstractor, IMachine machine) {
+		// XXX: the default path should be provided some other way
+		return wrapCommandAbstractorForSDK(commandAbstractor, machine,
+				"sb-conf", "/scratchbox/tools/bin");
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDKTarget.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDKTarget.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDKTarget.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.core;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.internal.api.scratchbox.core.sdk.AbstractScratchboxSDKTarget;
+import org.maemo.esbox.internal.scratchbox.sb1.command.GetGdbQemuCommandPatternCommand;
+import org.maemo.esbox.internal.scratchbox.sb1.launcher.Scratchbox1ProcessLauncherFactory;
+import org.maemo.mica.common.core.CorePreferenceConstants;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.IProcessLauncherFactory;
+import org.maemo.mica.common.core.sdk.ISDKPlatform;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * SDK target for Scratchbox 1
+ * 
+ * @author baranov
+ * 
+ */
+public class Scratchbox1SDKTarget extends AbstractScratchboxSDKTarget {
+
+	private IPath targetRoot;
+
+	public Scratchbox1SDKTarget(Scratchbox1SDK sdk, ISDKPlatform platform,
+			String architecture, String target, IPath targetRoot) {
+		super(sdk, platform, architecture, target);
+		this.targetRoot = targetRoot;
+		init(new Scratchbox1FileSystemMapping(sdk.getSDKRoot(), target, sdk
+				.getPreferenceValue(CorePreferenceConstants.USER)));
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#
+	 * getProcessLauncherFactoryForInstall()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactoryForInstall() {
+		return new Scratchbox1ProcessLauncherFactory(this, true);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.IScratchboxSDKTarget#getRootstrapPath()
+	 */
+	public IPath getRootstrapPath() {
+		return getSDKTargetRoot();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDKTarget#getProcessLauncherFactory()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactory() {
+		return new Scratchbox1ProcessLauncherFactory(this, false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDKTarget#getSDKTargetRoot()
+	 */
+	public IPath getSDKTargetRoot() {
+		return targetRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#
+	 * getGdbQemuCommandPattern(java.lang.String)
+	 */
+	public synchronized String getGdbQemuCommandPattern(String architecture)
+			throws MicaException {
+		GetGdbQemuCommandPatternCommand command = new GetGdbQemuCommandPatternCommand(
+				this, this.getCommandAbstractor());
+		List<String> arguments = new ArrayList<String>(1);
+		arguments.add(architecture);
+		return command.performCommand(arguments);
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1EnvironmentProvider.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1EnvironmentProvider.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1EnvironmentProvider.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb1.launcher;
+
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils.Results;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.common.core.IStandardEnvironmentProvider;
+
+import java.util.*;
+
+/**
+ * The standard environment provider for scratchbox caches the environment once
+ * per SDK target.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1EnvironmentProvider implements
+		IStandardEnvironmentProvider {
+	public static Map<ISDKTarget, Properties> cachedStdEnvMap = new HashMap<ISDKTarget, Properties>();
+	private final ISDKTarget sdkTarget;
+
+	/**
+	 * @param sdkTarget
+	 */
+	public Scratchbox1EnvironmentProvider(ISDKTarget sdkTarget) {
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * getRawEnvironment()
+	 */
+	public Properties getRawEnvironment() {
+		Properties standardEnv = cachedStdEnvMap.get(sdkTarget);
+		if (standardEnv == null) {
+			// gather arguments by querying a typical shell launched in POSIX
+			// mode (sh instead of bash)
+			Scratchbox1ProcessLauncher launcher = new Scratchbox1ProcessLauncher(
+					sdkTarget, null, CommandLineArguments.createFromVarArgs(
+							"sh", "-c", "set"), null);
+
+			try {
+				Results results = ProcessLauncherUtils
+						.launchAndReadStandardStreams(launcher, null);
+				standardEnv = EnvironmentProperties
+						.createFromShellEnvDump(results.stdout);
+			} catch (MicaException e) {
+				Activator
+						.getErrorLogger()
+						.logError(
+								"Failed to read scratchbox environment; using system environment",
+								e);
+				standardEnv = sdkTarget.getSDK().getMachine()
+						.getStandardEnvironment();
+			}
+
+			cachedStdEnvMap.put(sdkTarget, standardEnv);
+		}
+		return standardEnv;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * flushRawEnvironment()
+	 */
+	public void flushRawEnvironment() {
+		cachedStdEnvMap.remove(sdkTarget);
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncher.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncher.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncher.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb1.launcher;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.provider.FileInfo;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.env.IEnvironmentOperation;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * For SB 1, we need to use a "run.sh" wrapper script. The login program does
+ * not conserve variables set outside unless "-k" is passed, but we don't want
+ * to use that anyway, in order to have a clean SB environment.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1ProcessLauncher extends BaseSDKTargetProcessLauncher implements
+		IProcessLauncher {
+
+	/**
+	 * The name of a file copied from the plugin to the sb environment and used
+	 * to ensure environment variables can be passed.
+	 */
+	private static final String RUN_SCRIPT_NAME = "run.sh";
+
+	private ISDKTarget sdkTarget;
+	private List<String> originalArguments;
+
+	public Scratchbox1ProcessLauncher(ISDKTarget sdkTarget,
+			IPath workingDirectory, List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock) {
+		// in SB 1, the working directory, executable, args, and environment
+		// are encoded in a single command to a wrapper script
+		super(encodeArgumentArray(sdkTarget, workingDirectory, cmdLine,
+				environmentModifierBlock), null, null,
+				sdkTarget);
+		if (sdkTarget == null)
+			throw new IllegalArgumentException();
+		this.sdkTarget = sdkTarget;
+		this.originalArguments = cmdLine;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.internal.common.core.BaseProcessLauncher#getLaunchInfoPrefix()
+	 */
+	@Override
+	protected String getLaunchInfoPrefix() {
+		return sdkTarget + " ";
+	}
+
+	@Override
+	public String getCommandLineString() {
+		return CommandLineArguments.toCommandLine(originalArguments);
+	}
+
+	private static List<String> encodeArgumentArray(ISDKTarget sdkTarget,
+			IPath workingDirectory, List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock) {
+
+		// get the location where the launcher script will be copied on the
+		// target
+		String runScriptLocation = sdkTarget
+				.getPreferenceValue(SB1PreferenceConstants.RUN_SCRIPT_LOC);
+
+		// encode working directory inside scratchbox
+		if (workingDirectory == null) {
+			workingDirectory = new Path("/");
+		}
+
+		List<String> envArgs = encodeEnvironmentModifier(environmentModifierBlock);
+
+		// Encode the launch command by replacing the arguments
+		// representing template arguments with the actual values.
+		//
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+
+		substitutor.define("RUN_SCRIPT_DIRECTORY", runScriptLocation);
+		substitutor.define("RUN_SCRIPT", RUN_SCRIPT_NAME);
+		substitutor.define("DIRECTORY", workingDirectory.toPortableString());
+
+		String exportsString = CommandLineArguments.toString(envArgs,
+				",", false); //$NON-NLS-1$
+
+		substitutor.define("EXPORTS", exportsString);
+		substitutor.define("COMMAND", cmdLine.get(0));
+		substitutor.define("ARGS", CommandLineArguments.toCommandLine(cmdLine
+				.subList(1, cmdLine.size())));
+
+		// get the Scratchbox invocation pattern
+		String commandPattern = sdkTarget
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LOGIN_COMMAND);
+
+		// replace variables
+		commandPattern = substitutor.substitute(commandPattern);
+
+		List<String> commandArgs = CommandLineArguments
+				.createFromCommandLine(commandPattern);
+		return commandArgs;
+	}
+
+	/**
+	 * Encode the add/replace and delete operations to run.sh
+	 * 
+	 * @param environmentModifierBlock
+	 * @return list of modifier flags
+	 */
+	private static List<String> encodeEnvironmentModifier(
+			IEnvironmentModifierBlock environmentModifierBlock) {
+		List<String> mods = new ArrayList<String>();
+		if (environmentModifierBlock != null) {
+			for (IEnvironmentOperation operation : environmentModifierBlock
+					.getOperations()) {
+				if (operation.getValue() == null)
+					mods.add("-" + operation.getName());
+				else
+					mods.add(operation.getName() + "=" + operation.getValue());
+			}
+		}
+		if (mods.isEmpty()) {
+			mods.add("-"); // must have something for the argument to be
+			// detected by run.sh
+		}
+		return mods;
+	}
+
+	/* A flag is the best way to do this -- see below */
+	private static boolean copiedRunScript;
+
+	@Override
+	protected void setupForLaunch() throws MicaException {
+		super.setupForLaunch();
+		
+		// Ensure the run script is available.
+		//
+		// It's a little fishy to check the timestamps, since the timestamp of the
+		// script from the plugin may be extracted from a JAR and always look newer!
+		//
+		// So, just be cautious and set it up once per Eclipse session.
+		// 
+		// We don't want to waste time checking contents or being "smart" since
+		// this will just slow things down.
+
+		if (!copiedRunScript) {
+			IFileStore runScriptLocation = sdkTarget
+					.getMachineFileSystemAccess()
+					.getFileStore(
+							new Path(
+									sdkTarget
+											.getPreferenceValue(SB1PreferenceConstants.RUN_SCRIPT_LOC)));
+			IFileStore runScript = runScriptLocation.getChild(RUN_SCRIPT_NAME);
+
+			try {
+				runScriptLocation.mkdir(EFS.NONE, null);
+
+				OutputStream os = null;
+				InputStream is = null;
+				try {
+					os = runScript.openOutputStream(EFS.OVERWRITE, null);
+					is = Activator.getPluginRelativeInputStream("./conf/"
+							+ RUN_SCRIPT_NAME);
+					byte[] content = new byte[8192];
+					int len;
+					while ((len = is.read(content)) > 0) {
+						os.write(content, 0, len);
+					}
+				} finally {
+					Policy.close(os);
+					Policy.close(is);
+				}
+
+				FileInfo info = new FileInfo();
+				info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
+				runScript.putInfo(info, EFS.NONE, null);
+
+				copiedRunScript = true;
+
+			} catch (Exception e) {
+				throw (ScratchboxException) new ScratchboxException(
+						"Cannot copy run script to " + runScript).initCause(e);
+			}
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.internal.common.core.BaseProcessLauncher#doCreateProcess()
+	 */
+	@Override
+	protected Process doCreateProcess() throws Exception {
+		return sdkTarget.getSDK().getMachine().createProcess(
+				getLaunchCurrentWorkingDirectory(),
+				getLaunchCommandArguments(),
+				getLaunchEnvironmentModifierBlock(), isUsePTY());
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncherFactory.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncherFactory.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/launcher/Scratchbox1ProcessLauncherFactory.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb1.launcher;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.process.IProcessLauncher;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.common.core.BaseProcessLauncherFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1ProcessLauncherFactory extends
+		BaseProcessLauncherFactory {
+
+	protected ISDKTarget sdkTarget;
+	private final boolean runAsRoot;
+
+	public Scratchbox1ProcessLauncherFactory(ISDKTarget sdkTarget,
+			boolean runAsRoot) {
+		super(new Scratchbox1EnvironmentProvider(sdkTarget), false);
+		this.sdkTarget = sdkTarget;
+		this.runAsRoot = runAsRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.common.core.IProcessLauncherFactory#createProcessLauncher(org
+	 * .eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath,
+	 * org.maemo.mica.common.core.List<String>, java.util.Properties)
+	 */
+	protected IProcessLauncher doCreateProcessLauncher(IPath workingDirectory,
+			List<String> cmdLine, IEnvironmentModifierBlock envBlock) {
+
+		if (runAsRoot) {
+			cmdLine = new ArrayList<String>(cmdLine);
+			cmdLine.add(0, "fakeroot");
+		}
+		return new Scratchbox1ProcessLauncher(sdkTarget, workingDirectory,
+				cmdLine, envBlock);
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.provider;
+
+import org.eclipse.core.runtime.IStatus;
+import org.maemo.esbox.internal.api.scratchbox.core.sdk.CacheUtils;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.internal.scratchbox.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.mica.common.core.*;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
+import org.maemo.mica.common.core.sdk.*;
+import org.maemo.mica.internal.api.common.core.sdk.UserAwarePreferenceProviderWrapper;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This implementation of the SDK provider searches for SB1 targets using the
+ * 'sb-conf list --targets' command. If any aspect of SB1 communication fails,
+ * we assume SB1 is not installed.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1SDKProvider implements ISDKProvider {
+
+	// only 1.0.x+ supported right now
+	private static final String SCRATCHBOX_VERSION_PATTERN = "1\\.\\d+\\..*"; //$NON-NLS-1$
+
+	/**
+	 * 
+	 */
+	public Scratchbox1SDKProvider() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDKProvider#createSDKs()
+	 */
+	public List<ISDK> createSDKs() throws MicaException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		List<ISDK> sdks = new ArrayList<ISDK>();
+		for (IMachine machine : MachineRegistry.getInstance()
+				.getBuildMachines()) {
+			try {
+				IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
+						CorePreferenceManager.getInstance()
+								.getPreferenceProvider(), machine);
+				IScratchboxSDK sdk = getMachineSDKs(prefProvider, machine);
+				if (sdk != null) {
+					sdks.add(sdk);
+					sdk.refresh();
+				}
+			} catch (ScratchboxException e) {
+				logger.log(IStatus.INFO,
+						"Problem scanning Scratchbox 1 installation", e);
+			}
+		}
+		CacheUtils.getInstance().saveCachedData();
+		return sdks;
+	}
+
+	/**
+	 * @param prefProvider
+	 * @return
+	 * @throws ScratchboxException
+	 */
+	private IScratchboxSDK getMachineSDKs(IPreferenceProvider prefProvider,
+			IMachine machine) throws MicaException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		// only support one Scratchbox 1.x installation
+		String version = Scratchbox1SDK.getCurrentSboxVersion(machine);
+		if (version == null) {
+			// no scratchbox?
+			return null;
+		}
+
+		if (!version.matches(SCRATCHBOX_VERSION_PATTERN)) {
+			logger
+					.logError(
+							MessageFormat
+									.format(
+											"Only Scratchbox 1.x is supported (detected {0}); disabling Scratchbox 1 support",
+											version), null);
+			return null;
+		}
+
+		IScratchboxSDK sdk = new Scratchbox1SDK(machine, version, prefProvider);
+
+		return sdk;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb1.ui.adapters;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.internal.api.scratchbox.ui.adapters.MaemoScratchboxSDKManageTargetAdapterBase;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.internal.scratchbox.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.internal.scratchbox.sb1.ui.wizard.NewScratchbox1TargetWizard;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter;
+import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.maemosdk.ui.adapters.MaemoTargetRemover;
+
+import java.util.List;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoScratchbox1SDKManageTargetAdapter extends
+		MaemoScratchboxSDKManageTargetAdapterBase implements
+		ISDKManageTargetAdapter {
+
+	private Scratchbox1SDK sdk;
+
+	/**
+	 * @param adaptableObject
+	 */
+	public MaemoScratchbox1SDKManageTargetAdapter(Scratchbox1SDK sdk) {
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter#installSDKTargets
+	 * (org.eclipse.swt.widgets.Shell, java.util.List)
+	 */
+	public IStatus installSDKTargets(Shell shell, List<ISDKTarget> installed) {
+		NewScratchbox1TargetWizard targetWizard;
+
+		targetWizard = new NewScratchbox1TargetWizard(sdk);
+		WizardDialog dlg = new WizardDialog(shell, targetWizard);
+		if (dlg.open() == Dialog.OK) {
+			return Status.OK_STATUS;
+		}
+
+		return Policy.getCancelStatus(Activator.getDefault());
+	}
+
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.ui.adapters.
+	 * MaemoScratchboxSDKManageTargetAdapterBase
+	 * #createTargetRemover(org.eclipse.swt.widgets.Shell,
+	 * org.maemo.mica.common.core.sdk.ISDKTarget, boolean)
+	 */
+	protected MaemoTargetRemover createTargetRemover(Shell shell,
+			ISDKTarget target, boolean deleteRootstrap) {
+		return new MaemoTargetRemover(shell, target, deleteRootstrap) {
+
+			@Override
+			protected void doDeleteTargetRootstrap(IProgressMonitor monitor,
+					ISDK sdk) {
+				monitor.worked(1);
+			}
+			
+			/* (non-Javadoc)
+			 * @see org.maemo.mica.internal.api.maemosdk.ui.adapters.ESboxTargetRemover#doRemoveTarget(org.maemo.mica.common.core.sdk.ISDK, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+			 */
+			@Override
+			protected void doRemoveTarget(ISDK sdk, String targetName,
+					IProgressMonitor monitor) throws MicaException {
+				((IScratchboxSDK) sdk).removeTarget(targetName);
+				monitor.worked(1);
+			}
+		};
+	}
+
+	@Override
+	protected boolean isRootStrapUsed(ISDKTarget selectedTarget) {
+		return false;
+	}
+	
+	
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapterFactory.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapterFactory.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapterFactory.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb1.ui.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.esbox.internal.scratchbox.sb1.core.Scratchbox1SDK;
+import org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoScratchbox1SDKManageTargetAdapterFactory implements IAdapterFactory {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
+	 * java.lang.Class)
+	 */
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(ISDKManageTargetAdapter.class)) {
+			if (adaptableObject instanceof Scratchbox1SDK) {
+				return new MaemoScratchbox1SDKManageTargetAdapter(
+						(Scratchbox1SDK) adaptableObject);
+			}
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	public Class[] getAdapterList() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapter.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapter.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapter.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb1.ui.adapters;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.maemo.esbox.internal.api.maemosdk.core.tools.MaemoLauncher;
+import org.maemo.esbox.internal.api.maemosdk.core.tools.XLauncher;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.GeneralUtils;
+import org.maemo.mica.common.core.adapters.IPrepareTargetProcessLaunchAdapter;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+/**
+ * Utility class to handle switching scratchbox targets and get user approval to
+ * kill existing sessions if needed.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1PrepareTargetProcessLaunchAdapter implements IPrepareTargetProcessLaunchAdapter {
+
+	private final ISDKTarget sdkTarget;
+	public Scratchbox1PrepareTargetProcessLaunchAdapter(ISDKTarget sdkTarget) {
+		this.sdkTarget = sdkTarget;
+	}
+	
+	public void prepareTargetForProcessLaunch() throws MicaException {
+		IScratchbox1SDK sdk = ((IScratchbox1SDK) sdkTarget.getSDK());
+		final String currentTarget = sdk.getCurrentTarget();
+		final String targetName = sdkTarget.getName();
+		if (currentTarget.equals(targetName)) {
+			return;
+		}
+
+		// see if maemo is running, since it needs to be killed to switch
+		// targets
+		// but isn't considered a "session" every time
+		boolean isMaemoRunning = MaemoLauncher.getInstance().isMaemoRunning(sdkTarget);
+
+		// now try to switch and see if shells are open
+		boolean failedToSwitch = false;
+		try {
+			sdk.selectTarget(targetName);
+		} catch (final ScratchboxException e) {
+			// sb-conf: You must close your other Scratchbox sessions first
+			// or
+			// Note: Couldn't reselect the target. There are other Scratchbox
+			// sessions open.
+			if (e.getLocalizedMessage().contains("Scratchbox sessions")) {
+				failedToSwitch = true;
+			} else {
+				throw e;
+			}
+		}
+
+		if (isMaemoRunning || failedToSwitch) {
+			final boolean[] ret = { false };
+
+			if (!GeneralUtils.isJUnitRunning()) {
+				Display.getDefault().syncExec(new Runnable() {
+					public void run() {
+						ret[0] = MessageDialog.openQuestion(null,
+							"Scratchbox Target Conflict",
+							MessageFormat.format(
+								"The scratchbox 1 target needs to be switched from ''{0}'' to ''{1}'', but existing sessions are active.\n\n"
+									+ "Kill existing Scratchbox sessions?  (You may manually close them first, if desired, then select 'No' to retry)",
+							currentTarget,
+							targetName));
+					};
+				});
+			} else {
+				ret[0] = true;
+			}
+
+			// if user accepts, kill existing ones
+			if (ret[0]) {
+				if (isMaemoRunning) {
+					// a target selection may succeed even if X and maemo are
+					// running... kill them first.
+					// We kill X too because some processes won't be killed by
+					// maemo-launcher.
+					try {
+						MaemoLauncher.getInstance().killMaemo(sdkTarget);
+					} catch (MicaException e2) {
+						// ignore
+					}
+					try {
+						XLauncher.getInstance().stopX(sdkTarget);
+					} catch (MicaException e2) {
+						// ignore
+					}
+				}
+
+				// now kill the scratchbox sessions the "approved" way
+				try {
+					sdk.killProcess();
+
+					// wait politely
+					try {
+						Thread.sleep(1000);
+					} catch (InterruptedException e1) {
+
+					}
+
+				} catch (ScratchboxException e2) {
+					// sb-conf killall can fail in the event there is some
+					// process with a space in its
+					// name... just log it and keep going
+					Activator.getErrorLogger().logError(
+							"Problem killing scratchbox sessions", e2);
+				}
+
+				// double-check, since it doesn't really work!
+				List<String> sessions = sdk.getSessions();
+				if (sessions.size() > 0) {
+					// forcibly kill processes
+					List<String> cmdLine = CommandLineArguments
+							.createFromVarArgs("kill", "-9");
+					cmdLine.addAll(sessions);
+
+					IProcessLauncher processLauncher = ProcessLauncherCreator
+							.createProcessLauncher(sdk
+									.getMachineProcessLauncherFactory(), null,
+									cmdLine);
+					Process process;
+					try {
+						process = processLauncher.createProcess();
+						process.waitFor();
+					} catch (final Exception e1) {
+						Display.getDefault().syncExec(new Runnable() {
+							public void run() {
+								MessageDialog.openError(null, "Scratchbox Target Conflict",
+									MessageFormat.format(
+										"Couldn''t kill scratchbox processes:\n\n{0}\n\nRetrying the target selection anyway.",
+										e1.getLocalizedMessage()));
+							};
+						});
+					}
+				}
+
+			}
+
+			// always retry, and rethrow if fails
+			sdk.selectTarget(targetName);
+		}
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapterFactory.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapterFactory.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/adapters/Scratchbox1PrepareTargetProcessLaunchAdapterFactory.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb1.ui.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
+import org.maemo.mica.common.core.adapters.IPrepareTargetProcessLaunchAdapter;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+
+/**
+ * 
+ * @author eswartz
+ *
+ */
+public class Scratchbox1PrepareTargetProcessLaunchAdapterFactory implements IAdapterFactory {
+
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+	 */
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(IPrepareTargetProcessLaunchAdapter.class)) {
+			if (adaptableObject instanceof ISDKTarget
+					&& ((ISDKTarget) adaptableObject).getSDK() instanceof IScratchbox1SDK) {
+				ISDKTarget sdkTarget = (ISDKTarget) adaptableObject;
+				return new Scratchbox1PrepareTargetProcessLaunchAdapter(sdkTarget);
+			}
+		}
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	public Class[] getAdapterList() {
+		return new Class[] { IPrepareTargetProcessLaunchAdapter.class };
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/preferences/Scratchbox1PreferencesPage.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/preferences/Scratchbox1PreferencesPage.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/preferences/Scratchbox1PreferencesPage.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * 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:
+ *    Paulo Romulo (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb1.ui.preferences;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.preference.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.maemo.esbox.internal.scratchbox.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.esbox.scratchbox.core.sdk.ScratchboxSDKFacade;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
+import org.maemo.mica.common.core.machine.ILocalMachine;
+import org.maemo.mica.common.core.sdk.SDKFactory;
+
+/**
+ * General preference page for scratchbox 1
+ * 
+ * @author romulo
+ */
+public class Scratchbox1PreferencesPage extends FieldEditorPreferencePage
+		implements IWorkbenchPreferencePage {
+
+	/**
+	 * Field for sandbox root
+	 */
+	private DirectoryFieldEditor feSandboxRoot = null;
+	private StringFieldEditor feSandboxRootStr = null;
+
+	/**
+	 * Field for run scratchbox commands
+	 */
+	private StringFieldEditor feSboxCommands = null;
+	protected boolean sdksChanged;
+	private String origSandboxRoot;
+
+	// private StringFieldEditor feGdbQemuCommand;
+
+	/**
+	 * The constructor
+	 */
+	public Scratchbox1PreferencesPage() {
+		super(GRID);
+		setPreferenceStore(SB1PreferenceConstants.getPreferenceStore());
+		setDescription("Options configuring scratchbox 1");
+		origSandboxRoot = getPreferenceStore().getString(
+				SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
+	 * ()
+	 */
+	public void createFieldEditors() {
+		IScratchboxSDK sdk = null;
+		try {
+			sdk = ScratchboxSDKFacade.getInstance().getScratchboxSDK(
+					IScratchbox1SDK.class).get(0);
+		} catch (ScratchboxException e) {
+		}
+		if (false && sdk != null && sdk.getMachine() instanceof ILocalMachine) {
+			feSandboxRoot = new DirectoryFieldEditor(
+					SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString(),
+					"Sandbox root directory:", getFieldEditorParent());
+			addField(feSandboxRoot);
+			feSandboxRoot.getTextControl(getFieldEditorParent())
+					.addModifyListener(new ModifyListener() {
+
+						public void modifyText(ModifyEvent e) {
+							sdksChanged = true;
+						}
+
+					});
+		} else {
+			feSandboxRootStr = new StringFieldEditor(
+					SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString(),
+					"Sandbox root directory:", getFieldEditorParent());
+			addField(feSandboxRootStr);
+			feSandboxRootStr.getTextControl(getFieldEditorParent())
+					.addModifyListener(new ModifyListener() {
+
+						public void modifyText(ModifyEvent e) {
+							sdksChanged = true;
+						}
+
+					});
+		}
+
+		feSboxCommands = new StringFieldEditor(
+				SB1PreferenceConstants.SB1_LOGIN_COMMAND.toString(),
+				"Command template:", getFieldEditorParent());
+
+		feSboxCommands
+				.getTextControl(getFieldEditorParent())
+				.setToolTipText(
+						"This setting should only be changed if you have very specific needs, like an alternate run script.");
+
+		// make this string manageable
+		int width;
+		GC gc = new GC(getFieldEditorParent().getShell());
+		width = gc.getAdvanceWidth('m') * 32;
+		gc.dispose();
+
+		GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+		gridData.widthHint = width;
+		feSboxCommands.getTextControl(getFieldEditorParent()).setLayoutData(
+				gridData);
+
+		addField(feSboxCommands);
+
+		// addField(feGdbQemuCommand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	public void init(IWorkbench workbench) {
+		// Nothing to do
+	}
+
+	@Override
+	public boolean performOk() {
+		boolean ret = super.performOk();
+		if (ret) {
+			if (sdksChanged) {
+				String curSandboxRoot = getPreferenceStore().getString(
+						SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString());
+				if (!curSandboxRoot.equals(origSandboxRoot)) {
+					SDKFactory.getInstance().refresh(new NullProgressMonitor());
+					origSandboxRoot = curSandboxRoot;
+				}
+			}
+		}
+		return ret;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Carolina Nogueira de Souza (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.ui.wizard;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.*;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.*;
+import org.maemo.esbox.internal.api.scratchbox.ui.wizards.*;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.internal.scratchbox.sb1.core.Scratchbox1SDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.ErrorLogger;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.maemosdk.ui.wizards.sbrsh.SbrshConfigurationNFSServer;
+import org.maemo.mica.internal.api.maemosdk.ui.wizards.sbrsh.SbrshConfigurationTargetDevice;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * The target wizard provides a easy way to create a target for Scratchbox. As
+ * Scratchbox target configuration, the user can configure your target.
+ * 
+ */
+public class NewScratchbox1TargetWizard extends Wizard implements INewWizard {
+
+	protected WizardPage targetNamePage;
+	protected WizardPage compilerNamePage;
+	protected WizardPage devkitsName;
+	protected WizardPage cpuMethodName;
+	protected WizardPage sbrshConfigTargetDevice;
+	protected WizardPage sbrshConfigNFSServer;
+	protected IProject generatedProject;
+
+	private Scratchbox1SDK sdk;
+
+	protected ISDKTarget createdTarget;
+
+	private void initialize() {
+		setNeedsProgressMonitor(true);
+		setWindowTitle("New Scratchbox 1 Target");
+		ImageDescriptor image = Activator
+				.getImageDescriptor("./icons/full/wizban/newtarget_wiz.gif");
+		setDefaultPageImageDescriptor(image);
+		initPages();
+	}
+
+	/**
+	 * Constructs a new target wizard for the given SDK (from the target
+	 * configuration page)
+	 * 
+	 * @param sdk
+	 */
+	public NewScratchbox1TargetWizard(Scratchbox1SDK sdk) {
+		super();
+		this.sdk = sdk;
+		initialize();
+	}
+
+	/**
+	 * Inicializes the content of the pages.
+	 */
+	private void initPages() {
+		if (sdk != null) {
+			targetNamePage = TargetWizardPageFactory.getInstance()
+					.createNamePage(sdk);
+			addPage(targetNamePage);
+			compilerNamePage = TargetWizardPageFactory.getInstance()
+					.createCompilerPage(sdk);
+			addPage(compilerNamePage);
+			devkitsName = new TargetWizardDevkitsPage(sdk);
+			addPage(devkitsName);
+			cpuMethodName = TargetWizardPageFactory.getInstance()
+					.createCPUMethod(sdk);
+			addPage(cpuMethodName);
+			sbrshConfigTargetDevice = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigDeviceTargetPage();
+			addPage(sbrshConfigTargetDevice);
+			sbrshConfigNFSServer = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigNFSSServer();
+			addPage(sbrshConfigNFSServer);
+		} else {
+			addPage(TargetWizardPageFactory.getInstance()
+					.createBadInstallationPage());
+		}
+	}
+
+	public boolean canFinish() {
+		if (sdk == null)
+			return false;
+
+		boolean nonCustomRootstrap = true;
+		boolean cpuPage = ((TargetWizardCPUMethod) cpuMethodName).canFinish();
+		boolean configDevice = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.canFinish();
+		boolean NFSServer = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.canFinish();
+		boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+
+		if (!sbrshConfigAccepted && (nonCustomRootstrap || cpuPage))
+			return true;
+		if (sbrshConfigAccepted && NFSServer && configDevice)
+			return true;
+
+		return false;
+	}
+
+	@Override
+	public IWizardPage getNextPage(IWizardPage page) {
+		if (page == cpuMethodName) {
+			boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+					.getSbrshConfigure();
+			if (!sbrshConfigAccepted) // user does not want to configure sbrsh
+				return null;
+			else
+				// user wants to configure sbrsh
+				return super.getNextPage(page);
+		}
+		return super.getNextPage(page);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
+	 */
+	public boolean performFinish() {
+		if (!setupTargetFromScratch())
+			return false;
+
+		boolean sbrshConfigSelected = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+		if (sbrshConfigSelected) {
+			configureSbrshService();
+			showsDialog();
+		}
+
+		return true;
+	}
+
+	private boolean setupTargetFromScratch() {
+		String targetName;
+		// in this mode, construct a target from the user's settings
+		targetName = getTargetNameSelected();
+		String compilerName = getCompilerNameSelected();
+		String cpuMethod = getCputranspSelected();
+		try {
+
+			String devkits = getDevkitsSelected();
+			// ScratchboxFacade.getInstance().createTarget((IScratchbox1SDK)
+			// sdk, targetName, compilerName, devkits, cpuMethod);
+			sdk.createTarget(targetName, compilerName, devkits, cpuMethod);
+
+			createdTarget = sdk.findSDKTarget(targetName);
+			return true;
+		} catch (MicaException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot get create target "
+					+ targetName, e);
+			return false;
+		}
+	}
+
+	/**
+	 * Return the name of the target to be created.
+	 * 
+	 * @return the name of the target to be created.
+	 */
+	private String getTargetNameSelected() {
+		return ((TargetWizardNamePage) targetNamePage).getTextControl()
+				.getText();
+	}
+
+	/**
+	 * Return the compiler name of the target to be created.
+	 * 
+	 * @return the compiler name of the target to be created.
+	 */
+	private String getCompilerNameSelected() {
+		TableItem item = ((TargetWizardCompilerPage) compilerNamePage)
+				.getTableControl().getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Return the devkits selected.
+	 * 
+	 * @return the devkits selected.
+	 */
+	private String getDevkitsSelected() {
+		String devkits = "";
+		TableItem devkitsSelected[] = ((TargetWizardDevkitsPage) devkitsName).table
+				.getSelection();
+		String separator = "";
+		for (int i = 0; i < devkitsSelected.length; i++) {
+			TableItem devkit = devkitsSelected[i];
+			devkits += separator + devkit.getText();
+			separator = ":";
+		}
+		return devkits;
+	}
+
+	/**
+	 * Return the cputransp name of the target to be created.
+	 * 
+	 * @return the cputransp name of the target to be created.
+	 */
+	private String getCputranspSelected() {
+		TableItem item = ((TargetWizardCPUMethod) cpuMethodName).getTable()
+				.getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Configure sbrsh service.
+	 */
+	private void configureSbrshService() {
+		String targetName = getTargetNameSelected();
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceAddr();
+		String nfsHostname = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.getNFSHostname();
+
+		try {
+			// ScratchboxFacade.getInstance().configureSbrsh(sdk, targetName,
+			// deviceTargetAddr, nfsHostname);
+			sdk.configureSbrsh(targetName, deviceTargetAddr, nfsHostname);
+		} catch (MicaException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot configure sbrsh", e);
+		}
+	}
+
+	/**
+	 * Add user at access list of the sbrshd running at the target device.
+	 */
+	private void addUser() {
+		String deviceTargetIP = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String username = System.getProperty("user.name");
+		ErrorLogger errorLogger = Activator.getErrorLogger();
+
+		try {
+			String localAddr = getLocalIP();
+			// ScratchboxFacade.getInstance().addSbrshAccessList(sdk,
+			// deviceTargetIP, username, localAddr);
+			sdk.addSbrshAccessList(deviceTargetIP, username, localAddr);
+		} catch (MicaException e) {
+			errorLogger
+					.logAndShowError(
+							"Cannot add user to the access list of sbrshd at the target device",
+							e);
+		} catch (UnknownHostException e) {
+			errorLogger.logAndShowError("Cannot get local IP address", e);
+		}
+	}
+
+	/**
+	 * Shows the dialog to ask the user if s/he wants to add his/herself to the
+	 * acess list of the sbrshd.
+	 */
+	private void showsDialog() {
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String text = "Do you want to add yourself to the access list of the sbrshd running on target device? \n";
+		text += "(This requires that "
+				+ deviceTargetAddr
+				+ " has ssh daemon running and sbrshd already installed, and that you have root access).";
+		boolean userAddedAtAccessList = MessageDialog.openQuestion(getShell(),
+				"Scratchbox Configuration", text);
+		if (userAddedAtAccessList) {
+			addUser();
+		}
+	}
+
+	/**
+	 * Get the local IP address.
+	 * 
+	 * @return the local IP address.
+	 * @throws UnknownHostException
+	 */
+	private String getLocalIP() throws UnknownHostException {
+		return InetAddress.getLocalHost().getHostAddress();
+	}
+
+	/**
+	 * We will accept the selection in the workbench to see if we can initialize
+	 * from it.
+	 * 
+	 * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+	 */
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+	}
+
+	/**
+	 * Get the target created. Only valid after wizard dialog completes.
+	 * 
+	 * @return newly created ISDKTarget or <code>null</code>
+	 */
+	public ISDKTarget getCreatedTarget() {
+		return createdTarget;
+	}
+
+}
\ No newline at end of file

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/TargetWizardDevkitsPage.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/TargetWizardDevkitsPage.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/TargetWizardDevkitsPage.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Carolina Nogueira de Souza (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb1.ui.wizard;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.internal.scratchbox.sb1.core.Scratchbox1SDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.ErrorLogger;
+import org.maemo.mica.internal.api.maemosdk.ui.wizards.IValidatePage;
+
+import java.util.List;
+
+/**
+ * This pages shows the devkits that the user can choose for his/her target.
+ * 
+ */
+public class TargetWizardDevkitsPage extends WizardPage implements
+		IValidatePage {
+
+	protected Table table;
+	private Scratchbox1SDK sdk;
+
+	/**
+	 * Constructs a NewTargetWizardDevkitsPage.
+	 */
+	protected TargetWizardDevkitsPage(Scratchbox1SDK sdk) {
+		super("Devkit");
+		this.sdk = sdk;
+		setTitle("Devkit");
+		setDescription("Select devkits");
+		setPageComplete(false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+	 * .Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		composite.setLayout(new GridLayout(1, false));
+
+		Label label = new Label(composite, SWT.LEFT);
+		label.setText("Devkits");
+
+		table = new Table(composite, SWT.MULTI | SWT.CHECK | SWT.BORDER);
+		table.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+		table.setHeaderVisible(false);
+		table.setLinesVisible(true);
+		table.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				validatePage();
+			}
+		});
+
+		inicializeTable();
+
+		setControl(composite);
+	}
+
+	/**
+	 * Inicializes the contents of the table.
+	 */
+	private void inicializeTable() {
+		TableItem item = null;
+		List<String> devkits = null;
+		try {
+			// devkits = ScratchboxFacade.getInstance().getDevkits(sdk);
+			devkits = sdk.getDevkits();
+		} catch (MicaException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot get list of devkits", e);
+			return;
+		}
+		for (String devkit : devkits) {
+			item = new TableItem(table, SWT.NONE);
+			item.setText(devkit);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage
+	 * #perfomeAction()
+	 */
+	public boolean validatePage() {
+		TableItem[] items = table.getItems();
+		boolean noneSelected = false;
+		boolean pageOK = false;
+		// verifies if at least one option was checked.
+		for (int i = 0; i < items.length; i++) {
+			TableItem item = items[i];
+			if (item.getChecked()) {
+				pageOK = true;
+				break;
+			}
+		}
+		// verifies if the options were choosen properly.
+		for (int i = 0; i < items.length; i++) {
+			TableItem item = items[i];
+			// verifies if any item was selected.
+			if (item.getChecked()) {
+				// verifies if "none" was selected.
+				if (item.getText().equals("none")) {
+					noneSelected = true;
+					// the user cant select another devkit if "none" was
+					// selected.
+				} else {
+					pageOK = !noneSelected;
+				}
+			}
+		}
+		if (noneSelected && !pageOK) {
+			setErrorMessage("Selected corrects devkits.");
+		} else {
+			String msg = pageOK ? null : "Select at least one option";
+			setErrorMessage(msg);
+		}
+		setPageComplete(pageOK);
+		return pageOK;
+	}
+}
\ No newline at end of file

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1/sdk/IScratchbox1SDK.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1/sdk/IScratchbox1SDK.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/scratchbox/sb1/sdk/IScratchbox1SDK.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.scratchbox.sb1.sdk;
+
+import java.util.List;
+
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.mica.common.core.MicaException;
+
+/**
+ * @author baranov
+ * 
+ */
+public interface IScratchbox1SDK extends IScratchboxSDK {
+	public static final String NAME = "Scratchbox 1";
+
+	/**
+	 * Return the list of available devkits at Scratchbox.
+	 * 
+	 * @return a list with the available devkits at Scratchbox.
+	 * @throws MicaException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public List<String> getDevkits() throws MicaException;
+
+	/**
+	 * Return the current sessions of Scratchbox.
+	 * 
+	 * @return a list with current sessions Scratchbox.
+	 * @throws MicaException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public List<String> getSessions() throws MicaException;
+
+	/**
+	 * Select another available target as current Scratchbox target.
+	 * 
+	 * @param targetName
+	 *            the name of the new target.
+	 * @return true, if the operation is performed successfully.
+	 * @throws MicaException
+	 *             if the target to be selected does not exists or if some
+	 *             problem related to Scratchbox communication occurs.
+	 */
+	public boolean selectTarget(String targetName) throws MicaException;
+
+	/**
+	 * Kill an Scratchbox process.
+	 * 
+	 * @return true, if the is performed successfully.
+	 * @throws MicaException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean killProcess() throws MicaException;
+
+	/**
+	 * Kill an Scratchbox process.
+	 * 
+	 * @param signal
+	 *            the signal emitted to scratchbox processes.
+	 * @return true, if the is performed successfully.
+	 * @throws MicaException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean killProcess(String signal) throws MicaException;
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.classpath
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.classpath	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.classpath	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.project
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.project	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/.project	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.maemo.esbox.scratchbox.sb2</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/META-INF/MANIFEST.MF
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/META-INF/MANIFEST.MF	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/META-INF/MANIFEST.MF	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ESbox Scratchbox 2 Support
+Bundle-SymbolicName: org.maemo.esbox.scratchbox.sb2;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.maemo.esbox.internal.scratchbox.sb2.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.maemo.mica.maemosdk.core;bundle-version="2.0.0";visibility:=reexport,
+ org.eclipse.ui.ide,
+ org.maemo.mica.maemosdk.ui;bundle-version="2.0.0",
+ org.maemo.esbox.scratchbox.core;bundle-version="2.0.0",
+ org.maemo.esbox.scratchbox.ui;bundle-version="2.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.maemo.esbox.internal.api.scratchbox.sb2.core,
+ org.maemo.esbox.internal.scratchbox.sb2.command;x-friends:="org.maemo.esbox.scratchbox.tests",
+ org.maemo.esbox.internal.scratchbox.sb2.core;x-friends:="org.maemo.esbox.scratchbox.tests",
+ org.maemo.esbox.internal.scratchbox.sb2.provider;x-friends:="org.maemo.esbox.scratchbox.tests",
+ org.maemo.esbox.scratchbox.sb2.sdk
+Bundle-Vendor: INdT / Nokia

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/build.properties
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/build.properties	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/build.properties	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               conf/,\
+               icons/

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/conf/sb2_prefs.xml
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/conf/sb2_prefs.xml	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/conf/sb2_prefs.xml	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+
+<properties>
+	<comment>This file contains the default settings for Scratchbox 2 preferences; 
+	see the org.maemo.mica.common.core.preference_set_provider extension</comment>
+
+	<!-- WHEN ANY DEFAULTS CHANGED warranting rewriting prefs, 
+		bump pref version in esbox_common.xml and adjust ESboxPreferenceInitializer#RPEFS_VERSION_MAJOR ;
+		WHEN ANYTHING ELSE CHANGED which can be merged into existing prefs, 
+		adjust ESboxPreferenceInitializer#RPEFS_VERSION_MINOR -->
+
+	<entry key="SB2_MAPPING_MODE">maemo</entry>
+	<entry key="SB2_INSTALL_MAPPING_MODE">emulate</entry>
+	<entry key="SB2_LOG_LEVEL"></entry>
+	
+	<entry key="SB2_EXEC_COMMAND">sb2 -Qx -m ${MAPPING_MODE} ${LOG_OPTION} -t ${TARGET} "${{COMMAND}} ${{ARGS}}"</entry>
+
+	<!-- this qemu-arm link is expected to be valid; we don't try to substitute unlike for sb1: see GetGdbQemuCommandPatternCommand -->
+	<entry key="SB2_GDB_REMOTE_QEMU">sb2-qemu-arm -g ${PORT}</entry>
+	
+	<!-- The hash-bang in these scripts don't properly launch bash! -->
+	<entry key="SB2_INIT_COMMAND">/bin/bash -c "sb2-init ${{OPTIONS}} ${{TARGET}} ${{COMPILER}}"</entry>	
+	<entry key="SB2_CONFIG_COMMAND">/bin/bash -c "sb2-config ${{ACTIONS}} ${{OPTIONS}}"</entry>	
+	<entry key="SB2_MAEMO_ROOTSTRAP_COMMAND">/bin/bash -c "maemo-rootstrap ${{OPTIONS}}"</entry>	
+	<entry key="SB2_SB2_SHOW_COMMAND">sb2-show</entry>	
+	
+	<!-- actions of command sb2-config -->	
+	
+	<entry key="SB2_VERSION_ACT">-v</entry>
+	<entry key="SB2_LIST_ACT">-l</entry>
+	
+	<!-- actions of command maemo-rootstrap -->	
+	<entry key="SB2_MAEMO_ROOTSTRAP_HOST_TOOLS_OPT">--host-tools</entry>	
+	<entry key="SB2_MAEMO_ROOTSTRAP_FORCE_OPT">--force</entry>	
+	<entry key="SB2_MAEMO_ROOTSTRAP_AVAILABLE_ACT">available</entry>
+	<entry key="SB2_MAEMO_ROOTSTRAP_LIST_ACT">list</entry>
+	<entry key="SB2_MAEMO_ROOTSTRAP_INSTALL_ACT">install</entry>
+	<entry key="SB2_MAEMO_ROOTSTRAP_REMOVE_ACT">remove</entry>
+	<entry key="SB2_MAEMO_ROOTSTRAP_PATH_ACT">path</entry>
+	
+	<!-- actions of command sb2-show -->	
+	<entry key="SB2_SB2_SHOW_PATH_ACTION">path</entry>	
+	<entry key="SB2_SB2_SHOW_PATH_OUTPUT_PATTERN">(.+)\s+=>\s+(\S+).*</entry>	
+	
+</properties>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/icons/full/obj16/maemoprj_obj.png
===================================================================
(Binary files differ)


Property changes on: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/icons/full/obj16/maemoprj_obj.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/plugin.xml
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/plugin.xml	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/plugin.xml	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+   <extension
+         point="org.maemo.mica.common.core.sdk_provider">
+      <sdk_provider
+            class="org.maemo.esbox.internal.scratchbox.sb2.provider.Scratchbox2SDKProvider">
+      </sdk_provider>
+   </extension>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            category="org.maemo.mica.common.ui.preferenceCategory.maemo"
+            class="org.maemo.esbox.internal.scratchbox.sb2.ui.preferences.Scratchbox2PreferencesPage"
+            id="org.maemo.mica.maemosdk.sb2.preferencePage.sb2"
+            name="Scratchbox 2">
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.core.runtime.adapters">
+      <factory
+            adaptableType="org.maemo.esbox.scratchbox.sb2.sdk.IScratchbox2SDK"
+            class="org.maemo.esbox.internal.scratchbox.sb2.ui.adapters.MaemoScratchbox2SDKManageTargetAdapterFactory">
+         <adapter
+               type="org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter">
+         </adapter>
+      </factory>
+   </extension>
+   <extension
+         point="org.maemo.mica.common.core.preference_set_provider">
+      <preferenceSetProvider
+            defaultsXMLFile="conf/sb2_prefs.xml"
+            preferenceConstantsClass="org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants"
+            preferenceMigratorClass="org.maemo.mica.internal.api.common.core.OldESboxPreferenceMigrator"
+            preferenceStoreBundle="org.maemo.esbox.scratchbox.sb2"
+            version="17">
+      </preferenceSetProvider>
+   </extension>
+   <!-- this was incorrectly refactored and is broken: there should be a single
+   	top-level wizard in mica.common.ui for this 
+   <extension
+         point="org.eclipse.ui.newWizards">
+      <wizard
+            class="org.maemo.esbox.internal.scratchbox.sb2.ui.wizard.NewScratchbox2TargetWizard"
+            icon="icons/full/obj16/maemoprj_obj.png"
+            id="org.maemo.mica.maemosdk.ui.scratchbox.targets.wizards.NewTargetWizard"
+            name="Scratchbox Targets">
+      </wizard>
+   </extension>
+   -->
+
+</plugin>

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2/core/SB2PreferenceConstants.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2/core/SB2PreferenceConstants.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/api/scratchbox/sb2/core/SB2PreferenceConstants.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.scratchbox.sb2.core;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+
+/**
+ * This class encapsulates the keys for preference constants defined by
+ * Scratchbox 2.
+ * 
+ * @author eswartz
+ * 
+ */
+public class SB2PreferenceConstants {
+	public static final int VERSION_MAJOR = 17;
+	public static final int VERSION_MINOR = 0;
+
+	/** Get the preference store that contains these preferences */
+	public static IPreferenceStore getPreferenceStore() {
+		return Activator.getDefault().getPreferenceStore();
+	}
+
+	/* SB2 configuration options */
+	public static final String SB2_GDB_REMOTE_QEMU = "SB2_GDB_REMOTE_QEMU";
+	public static final String SB2_CONFIG_COMMAND = "SB2_CONFIG_COMMAND";
+	public static final String SB2_EXEC_COMMAND = "SB2_EXEC_COMMAND";
+	public static final String SB2_INIT_COMMAND = "SB2_INIT_COMMAND";
+	public static final String SB2_VERSION_ACT = "SB2_VERSION_ACT";
+	public static final String SB2_LIST_ACT = "SB2_LIST_ACT";
+	public static final String SB2_MAPPING_MODE = "SB2_MAPPING_MODE";
+	public static final String SB2_INSTALL_MAPPING_MODE = "SB2_INSTALL_MAPPING_MODE";
+	public static final String SB2_LOG_LEVEL = "SB2_LOG_LEVEL";
+	public static final String SB2_INIT_OPT_COMPILER = "SB2_INIT_OPT_COMPILER";
+	public static final String SB2_MAEMO_ROOTSTRAP_COMMAND = "SB2_MAEMO_ROOTSTRAP_COMMAND";
+	public static final String SB2_MAEMO_ROOTSTRAP_AVAILABLE_ACT = "SB2_MAEMO_ROOTSTRAP_AVAILABLE_ACT";
+	public static final String SB2_MAEMO_ROOTSTRAP_LIST_ACT = "SB2_MAEMO_ROOTSTRAP_LIST_ACT";
+	public static final String SB2_MAEMO_ROOTSTRAP_INSTALL_ACT = "SB2_MAEMO_ROOTSTRAP_INSTALL_ACT";
+	public static final String SB2_MAEMO_ROOTSTRAP_FORCE_OPT = "SB2_MAEMO_ROOTSTRAP_FORCE_OPT";
+	public static final String SB2_MAEMO_ROOTSTRAP_HOST_TOOLS_OPT = "SB2_MAEMO_ROOTSTRAP_HOST_TOOLS_OPT";
+	public static final String SB2_MAEMO_ROOTSTRAP_REMOVE_ACT = "SB2_MAEMO_ROOTSTRAP_REMOVE_ACT";
+	public static final String SB2_SB2_SHOW_COMMAND = "SB2_SB2_SHOW_COMMAND";
+	public static final String SB2_SB2_SHOW_PATH_ACTION = "SB2_SB2_SHOW_PATH_ACTION";
+	public static final String SB2_SB2_SHOW_PATH_OUTPUT_PATTERN = "SB2_SB2_SHOW_PATH_OUTPUT_PATTERN";
+	public static final String SB2_MAEMO_ROOTSTRAP_PATH_ACT = "SB2_MAEMO_ROOTSTRAP_PATH_ACT";
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/Activator.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/Activator.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/Activator.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,157 @@
+package org.maemo.esbox.internal.scratchbox.sb2;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.maemo.mica.common.core.ErrorLogger;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.maemo.mica.maemosdk.sdk2";
+
+	// The shared instance
+	private static Activator plugin;
+
+	private IPreferenceStore preferenceStore;
+
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugin#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;
+	}
+
+	/**
+	 * 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();
+	}
+
+	/**
+	 * 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);
+	}
+
+	/**
+	 * 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 the preference store for this UI plug-in. This preference store
+	 * is used to hold persistent settings for this plug-in in the context of a
+	 * workbench. Some of these settings will be user controlled, whereas others
+	 * may be internal setting that are never exposed to the user.
+	 * <p>
+	 * If an error occurs reading the preference store, an empty preference
+	 * store is quietly created, initialized with defaults, and returned.
+	 * </p>
+	 * <p>
+	 * <strong>NOTE:</strong> As of Eclipse 3.1 this method is no longer
+	 * referring to the core runtime compatibility layer and so plug-ins relying
+	 * on Plugin#initializeDefaultPreferences will have to access the
+	 * compatibility layer themselves.
+	 * </p>
+	 * 
+	 * @return the preference store
+	 */
+	public IPreferenceStore getPreferenceStore() {
+		// Create the preference store lazily.
+		if (preferenceStore == null) {
+			preferenceStore = new ScopedPreferenceStore(new InstanceScope(),
+					getBundle().getSymbolicName());
+
+		}
+		return preferenceStore;
+	}
+
+	/**
+	 * @param object
+	 * @param e
+	 * @return
+	 */
+	public static IStatus createErrorStatus(String msg, Throwable t) {
+		return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/AbstractSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/AbstractSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/AbstractSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.AbstractSDKCommand;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.security.InvalidParameterException;
+
+public abstract class AbstractSb2Command extends AbstractSDKCommand {
+
+	public AbstractSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.command.AbstractSDKCommand#
+	 * replaceScratchboxConfigCommand(java.lang.String, java.lang.String[])
+	 */
+	public String replaceScratchboxConfigCommand(String action, String[] options)
+			throws InvalidParameterException {
+		String sboxCommand;
+
+		sboxCommand = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_CONFIG_COMMAND);
+
+		return replaceScratchboxCommand(sboxCommand, action, options);
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb2.command;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.CoreConsoleManager;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Creates a new rootstrap for a target, if it does not exist. This command
+ * wraps the callback to service:
+ * <p>
+ * maemo-rootstrap [--force] install &lt;target&gt;
+ * 
+ */
+public class CreateMaemoRootstrapSb2Command extends MaemoRootstrapSb2Command {
+
+	private ISDK sdk;
+	private IProgressMonitor monitor;
+
+	public CreateMaemoRootstrapSb2Command(ISDK sdk,
+			ICommandAbstractor commandAbstractor, IProgressMonitor monitor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+		this.monitor = monitor;
+	}
+
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 3;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Boolean performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String useHostToolsFlag = param.get(1);
+		String forceFlag = param.get(2);
+
+		List<String> params = new ArrayList<String>();
+		if (useHostToolsFlag.equals(Boolean.TRUE.toString())) {
+			params
+					.add(commandAbstractor
+							.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_HOST_TOOLS_OPT));
+		}
+		if (forceFlag.equals(Boolean.TRUE.toString())) {
+			params
+					.add(commandAbstractor
+							.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_FORCE_OPT));
+		}
+		params
+				.add(commandAbstractor
+						.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_INSTALL_ACT));
+		params.add(targetName);
+
+		IEnvironmentModifierBlock envBlock = commandAbstractor
+				.getProcessLauncherFactory().defaultEnvironmentModifierBlock();
+		ProcessLauncherUtils.defineProxyVariables(envBlock);
+
+		setMonitorAndConsole(monitor, CoreConsoleManager.getInstance().getConsole(true,
+				null, "Installing rootstrap " + targetName));
+		doPerformCommand(params, envBlock, 0);
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateTargetSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateTargetSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateTargetSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Creates a new target, if it does not exist. This command wraps the callback
+ * to service:
+ * <p>
+ * sb2-init {flags} [targetname] [compiler]
+ * 
+ */
+public class CreateTargetSb2Command extends AbstractSb2Command {
+
+	private ISDK sdk;
+
+	public CreateTargetSb2Command(ISDK sdk, ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() >= 3;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param) throws MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String compilerName = param.get(1);
+		String cpuTransp = param.get(2);
+
+		// remaining arguments are flags
+		String pattern = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_INIT_COMMAND);
+
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+		substitutor.define("TARGET", targetName);
+		substitutor.define("COMPILER", compilerName);
+
+		String options = "";
+		if (cpuTransp != null && cpuTransp.length() > 0) {
+			options += "-c " + cpuTransp;
+		}
+		substitutor.define("OPTIONS", options);
+
+		pattern = substitutor.substitute(pattern);
+
+		List<String> cmdLine = CommandLineArguments
+				.createFromCommandLine(pattern);
+
+		IProcessLauncher processLauncher = ProcessLauncherCreator
+				.createProcessLauncher(commandAbstractor
+						.getProcessLauncherFactory(), null, cmdLine);
+
+		Process process = processLauncher.createProcess();
+
+		processLauncher.redirectToConsole(true, null,
+				"Installing scratchbox2 target " + targetName);
+
+		try {
+			process.waitFor();
+		} catch (InterruptedException e) {
+			Activator.getErrorLogger().logError("Target installation aborted",
+					e);
+		}
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 3;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetCurrentTargetSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetCurrentTargetSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetCurrentTargetSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.*;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.io.*;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Get the current Scratchgox 2 target. There is no command to do this, so read
+ * $HOME/.scratchbox2/config
+ */
+public class GetCurrentTargetSb2Command extends AbstractSb2Command {
+
+	public GetCurrentTargetSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		IFileStore config = commandAbstractor
+				.getFileSystemAccess()
+				.getFileStore(
+						new Path("home")
+								.append(
+										commandAbstractor
+												.getPreferenceValue(CorePreferenceConstants.USER))
+								.append(".scratchbox2").append("config"));
+
+		InputStream is = null;
+		try {
+			is = config.openInputStream(EFS.NONE, null);
+			BufferedReader reader = new BufferedReader(
+					new InputStreamReader(is));
+			Pattern varPattern = Pattern
+					.compile("\\s*DEFAULT_TARGET\\s*=\\s*(\\S+)\\s*");
+			String line;
+			while ((line = reader.readLine()) != null) {
+				Matcher matcher = varPattern.matcher(line.trim());
+				if (matcher.matches()) {
+					return matcher.group(1);
+				}
+			}
+
+			return null;
+		} catch (IOException e) {
+			throw new ScratchboxException("Cannot read target from " + config
+					+ ": " + e.getMessage());
+		} catch (CoreException e) {
+			throw new ScratchboxException("Cannot read target from " + config
+					+ ": " + e.getMessage());
+		} finally {
+			Policy.close(is);
+		}
+
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetGdbQemuCommandPatternCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetGdbQemuCommandPatternCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetGdbQemuCommandPatternCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.SBPreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Get the command pattern for launching qemu with the debugger
+ * 
+ * @author eswartz
+ * 
+ */
+public class GetGdbQemuCommandPatternCommand extends AbstractSb2Command {
+	private IScratchboxSDKTarget sdkTarget;
+
+	public GetGdbQemuCommandPatternCommand(IScratchboxSDKTarget sdkTarget,
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String commandPattern = null;
+
+		String architecture = param.get(0);
+
+		if (architecture.equals(IScratchboxSDKTarget.ARCHITECTURE_ARMEL)) {
+			// we think this always uses a new enough version, so keep ${PORT}
+			commandPattern = sdkTarget
+					.getPreferenceValue(SB2PreferenceConstants.SB2_GDB_REMOTE_QEMU);
+		} else {
+			// The others, just standard "gdbserver" command.
+			commandPattern = sdkTarget
+					.getPreferenceValue(SBPreferenceConstants.SBOX_GDB_REMOTE);
+		}
+
+		return commandPattern;
+	}
+
+	/**
+	 * Find what qemu is configured for this target.
+	 * 
+	 * @return qemu name, or <code>null</code> if not using qemu
+	 */
+	protected String getConfiguredQemu() throws MicaException {
+		return null;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetMaemoRootstrapLocationCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetMaemoRootstrapLocationCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetMaemoRootstrapLocationCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class GetMaemoRootstrapLocationCommand extends MaemoRootstrapSb2Command {
+
+	private IScratchboxSDKTarget sdkTarget;
+
+	public GetMaemoRootstrapLocationCommand(
+			ICommandAbstractor commandAbstractor, IScratchboxSDKTarget sdkTarget) {
+		super(commandAbstractor);
+		this.sdkTarget = sdkTarget;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.internal.common.core.command.ICommand#performCommand(java.util
+	 * .List)
+	 */
+	public Object performCommand(List<String> params)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		List<String> rsCommands = new ArrayList<String>(2);
+
+		String pathAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_PATH_ACT);
+
+		rsCommands.add(pathAction);
+		rsCommands.add(sdkTarget.getName());
+
+		List<String> results = doPerformCommand(rsCommands, null, 0);
+		if (results.size() == 0)
+			throw new ScratchboxException(
+					"Could not detect rootstrap location for " + sdkTarget
+							+ "\ngot:\n" + catenateLines(results));
+
+		// ignore bogus report of deleted rootstrap
+		IPath root = new Path(results.get(0).trim());
+		IFileStore store = sdkTarget.getMachineFileSystemAccess().getFileStore(
+				root);
+		if (store.fetchInfo().exists())
+			return root;
+		else
+			throw new ScratchboxException("Rootstrap location for " + sdkTarget
+					+ " does not exist: " + store);
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetVersionScratchboxCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetVersionScratchboxCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/GetVersionScratchboxCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * Get the version of Scratchbox installed. This command wraps the callback to
+ * service sb-conf version.
+ * 
+ */
+public class GetVersionScratchboxCommand extends AbstractSb2Command {
+
+	public GetVersionScratchboxCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.ScratchboxCommand#getParametersSize()
+	 */
+	public int getParametersSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .util.List)
+	 */
+	public String performCommand(List<String> params)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String sboxVersionAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_VERSION_ACT);
+
+		String currentSboxVersionCommand = this
+				.replaceScratchboxConfigCommand(sboxVersionAction);
+
+		Process process = createProcess(currentSboxVersionCommand, null);
+
+		String currentVersion = getInputFromProcessAndWait(process, false, 0);
+
+		return currentVersion;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.sb2.sdk.MaemoRootstrap;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.*;
+
+/**
+ * List the maemo rootstraps available for installation.
+ */
+public class ListAvailableMaemoRootstrapsSb2Command extends
+		MaemoRootstrapSb2Command {
+
+	private static final int LIST_TIMEOUT = 10000;
+
+	public ListAvailableMaemoRootstrapsSb2Command(
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<MaemoRootstrap> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String availableAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_AVAILABLE_ACT);
+
+		// ensure the proxy is established
+		IEnvironmentModifierBlock proxyEnvBlock = commandAbstractor
+				.getProcessLauncherFactory().defaultEnvironmentModifierBlock();
+		ProcessLauncherUtils.defineProxyVariables(proxyEnvBlock);
+
+		List<String> available = doPerformCommand(Collections
+				.singletonList(availableAction), proxyEnvBlock, LIST_TIMEOUT);
+
+		// this output has a few header lines
+		List<MaemoRootstrap> targetsAvailable = new ArrayList<MaemoRootstrap>();
+
+		boolean gotHeader = false;
+		for (String line : available) {
+			if (line.contains("Nickname,")) {
+				gotHeader = true;
+				continue;
+			}
+			if (line.trim().length() == 0) {
+				continue;
+			}
+			if (!gotHeader) {
+				continue;
+			}
+
+			String[] tokens = line.split(",\\s*");
+			if (tokens.length == 3) {
+				targetsAvailable.add(new MaemoRootstrap(tokens[0], tokens[1],
+						tokens[2]));
+			}
+
+		}
+		return targetsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCompilersSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCompilersSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCompilersSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * List the installed compilers. There's no known command for this, but we can
+ * look in specific places.
+ * 
+ */
+public class ListCompilersSb2Command extends AbstractSb2Command {
+
+	public ListCompilersSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		List<String> compilersAvailable = new ArrayList<String>();
+
+		try {
+			IFileStore baseToolDir = commandAbstractor.getFileSystemAccess()
+					.getFileStore(new Path("/opt/maemo/tools"));
+			IFileStore[] kids = baseToolDir.childStores(EFS.NONE, null);
+			for (IFileStore baseDir : kids) {
+				IFileStore dir = baseDir.getChild("bin");
+				if (dir.fetchInfo().isDirectory()) {
+					IFileStore[] files = dir.childStores(EFS.NONE, null);
+					for (IFileStore file : files) {
+						if (file.getName().endsWith("-gcc")) {
+							compilersAvailable.add(file.toURI().getPath());
+							break;
+						}
+					}
+				}
+			}
+		} catch (CoreException e) {
+			Activator.getErrorLogger().logError("Error scanning compilers", e);
+		}
+		return compilersAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCputranspSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCputranspSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListCputranspSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.*;
+
+/**
+ * List the installed compilers. There's no known command for this, but we can
+ * look in specific places.
+ * 
+ */
+public class ListCputranspSb2Command extends AbstractSb2Command {
+
+	public ListCputranspSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		List<String> cputranspAvailable = new ArrayList<String>();
+
+		Set<String> expected = new HashSet<String>();
+		expected.add("sb2-qemu-arm");
+		expected.add("sbrsh");
+
+		Properties env = ProcessLauncherUtils
+				.getSynthesizedEnvironment(commandAbstractor
+						.getProcessLauncherFactory());
+		String pathenv = env.getProperty("PATH");
+		if (pathenv == null) {
+			pathenv = "/usr/bin:/bin"; // XXX
+		}
+		if (pathenv != null) {
+			String[] paths = pathenv.split(":");
+			for (String exp : expected) {
+				for (String path : paths) {
+					IFileStore bin = commandAbstractor.getFileSystemAccess()
+							.getFileStore(new Path(path).append(exp));
+					if (bin.fetchInfo().exists()) {
+						cputranspAvailable.add(bin.toURI().getPath());
+						break;
+					}
+				}
+			}
+		}
+
+		return cputranspAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * List the maemo rootstraps installed
+ */
+public class ListInstalledMaemoRootstrapsSb2Command extends
+		MaemoRootstrapSb2Command {
+
+	public ListInstalledMaemoRootstrapsSb2Command(
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String availableAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_LIST_ACT);
+
+		List<String> installed = doPerformCommand(Collections
+				.singletonList(availableAction), null, 0);
+
+		return installed;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListTargetsCommand.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListTargetsCommand.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ListTargetsCommand.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.List;
+
+/**
+ * List the installed targets. This command wraps the callback to service (sb1)
+ * sb-conf list --targets or sb2-config -l (sb2)
+ * 
+ */
+public class ListTargetsCommand extends AbstractSb2Command {
+
+	public ListTargetsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction;
+		String targetsOption;
+		listAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_LIST_ACT);
+		targetsOption = "";
+
+		String listTargetsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { targetsOption });
+
+		Process process = createProcess(listTargetsCommandString, null);
+
+		List<String> targetsAvailable = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		return targetsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/MaemoRootstrapSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/MaemoRootstrapSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/MaemoRootstrapSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.process.CommandLineArguments;
+import org.maemo.mica.common.core.process.ShellTemplateSubstitutor;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Base class for maemo rootstrap command.
+ */
+public abstract class MaemoRootstrapSb2Command extends AbstractSb2Command {
+
+	public MaemoRootstrapSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return true;
+	}
+
+	/**
+	 * Override if stderr output is allowed.
+	 * 
+	 * @return false
+	 */
+	protected boolean allowErrors() {
+		return false;
+
+	}
+
+	/**
+	 * Perform the command with the given params as command line arguments, with
+	 * an optional timeout (triggering ScratchboxException if reached)
+	 * 
+	 * @param params
+	 *            command line parameters to maemo-rootstrap
+	 * @param envBlock
+	 *            any environment needed or <code>null</code>
+	 * @param timeout
+	 *            if not 0, timeout in milliseconds
+	 * @return lines from stdout
+	 * @throws ScratchboxException
+	 *             if command execution fails or if timeout reached
+	 */
+	@SuppressWarnings("unchecked")
+	protected List<String> doPerformCommand(List<String> params,
+			IEnvironmentModifierBlock envBlock, long timeout)
+			throws MicaException {
+		String rootstrapCommand = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_COMMAND);
+
+		String options = CommandLineArguments.toCommandLine(params);
+
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+		substitutor.define("OPTIONS", options);
+
+		rootstrapCommand = substitutor.substitute(rootstrapCommand);
+
+		if (console == null) {
+			Process process = createProcess(rootstrapCommand, envBlock);
+			List<String> results = getLineInputFromProcessAndWait(process,
+					allowErrors(), timeout);
+			return results;
+		} else {
+			runAndWaitForProcess("Running " + rootstrapCommand,
+					rootstrapCommand, envBlock, timeout);
+			return Collections.EMPTY_LIST;
+		}
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveMaemoRootstrapSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveMaemoRootstrapSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveMaemoRootstrapSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.CoreConsoleManager;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Remove a maemo rootstrap. Parameters are target name and force boolean flag.
+ */
+public class RemoveMaemoRootstrapSb2Command extends MaemoRootstrapSb2Command {
+
+	private final IProgressMonitor monitor;
+
+	public RemoveMaemoRootstrapSb2Command(ICommandAbstractor commandAbstractor,
+			IProgressMonitor monitor) {
+		super(commandAbstractor);
+		this.monitor = monitor;
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 2;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Boolean performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String forceFlag = param.get(1);
+
+		String action = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_REMOVE_ACT);
+
+		List<String> commands = new ArrayList<String>();
+
+		if (forceFlag.equals(Boolean.TRUE.toString())) {
+			String force = commandAbstractor
+					.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_FORCE_OPT);
+			commands.add(force);
+		}
+		commands.add(action);
+		commands.add(targetName);
+
+		IEnvironmentModifierBlock envBlock = commandAbstractor
+				.getProcessLauncherFactory().defaultEnvironmentModifierBlock();
+		ProcessLauncherUtils.defineProxyVariables(envBlock);
+
+		setMonitorAndConsole(monitor, CoreConsoleManager.getInstance().getConsole(true,
+				null, "Removing rootstrap " + targetName));
+
+		doPerformCommand(commands, envBlock, 0);
+
+		return Boolean.TRUE;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveTargetSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveTargetSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/RemoveTargetSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.maemo.esbox.internal.scratchbox.sb2.core.Scratchbox2SDK;
+import org.maemo.esbox.scratchbox.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Remove a Scratchbox 2 target. There's no known command for this, but we can
+ * manually fix up the system.
+ * 
+ */
+public class RemoveTargetSb2Command extends AbstractSb2Command {
+
+	private Scratchbox2SDK sdk;
+
+	public RemoveTargetSb2Command(ISDK sdk, ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = (Scratchbox2SDK) sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, MicaException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetToRemove = param.get(0);
+		if (!targetExist(targetToRemove))
+			throw new ScratchboxInvalidParameterException("Target "
+					+ targetToRemove + " does not exist.");
+
+		IFileStore sb2Dir = commandAbstractor.getFileSystemAccess()
+				.getFileStore(sdk.getScratchbox2ConfigDirectory());
+		IFileStore targetDir = sb2Dir.getChild(targetToRemove);
+
+		if (!targetDir.fetchInfo().exists()) {
+			throw new ScratchboxInvalidParameterException("Target "
+					+ targetToRemove
+					+ " does not exist at the expected location: " + targetDir);
+		}
+
+		try {
+			targetDir.delete(EFS.NONE, null);
+		} catch (CoreException e) {
+			throw new ScratchboxException("Failed to delete rootstrap", e);
+		} finally {
+			sdk.refresh();
+		}
+
+		return true;
+	}
+
+	/**
+	 * Verify if a target exists.
+	 * 
+	 * @param targetToRemove
+	 *            the target to verify.
+	 * 
+	 * @return true, if the target exists in Scratchbox; false, otherwise.
+	 * @throws ScratchboxException
+	 *             if some problem occurrs while requesting Scratchbox services.
+	 */
+	private boolean targetExist(String targetToRemove) throws MicaException {
+		List<String> targetsAvailable = new ListTargetsCommand(
+				commandAbstractor).performCommand(new ArrayList<String>());
+		return targetsAvailable.contains(targetToRemove);
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ShowPathMappingSb2Command.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ShowPathMappingSb2Command.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/ShowPathMappingSb2Command.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.command;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+
+import java.io.ByteArrayOutputStream;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Invoke 'sb2-show path' on a list of paths and return the mappings, or
+ * <code>null</code> for unmapped entries
+ * 
+ * @author eswartz
+ * 
+ */
+public class ShowPathMappingSb2Command extends AbstractSb2Command {
+	public ShowPathMappingSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return true;
+	}
+
+	public Map<IPath, IPath> performCommand(List<String> params)
+			throws ScratchboxException, MicaException {
+		List<String> cmdLine = CommandLineArguments
+				.createFromVarArgs(
+						commandAbstractor
+								.getPreferenceValue(SB2PreferenceConstants.SB2_SB2_SHOW_COMMAND),
+						commandAbstractor
+								.getPreferenceValue(SB2PreferenceConstants.SB2_SB2_SHOW_PATH_ACTION));
+		cmdLine.addAll(params);
+
+		IProcessLauncher launcher = ProcessLauncherCreator
+				.createProcessLauncher(commandAbstractor
+						.getProcessLauncherFactory(), null, cmdLine);
+
+		launcher.createProcess();
+
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		ByteArrayOutputStream err = new ByteArrayOutputStream();
+		launcher.waitAndRead(out, err);
+
+		if (err.size() != 0)
+			throw new ScratchboxException(
+					"Cannot resolve scratchbox2 path mappings:\n" + err);
+
+		String resolveInfo = out.toString().trim();
+		String[] lines = resolveInfo.split("\r\n|\r|\n");
+
+		Map<IPath, IPath> result = new HashMap<IPath, IPath>(lines.length);
+
+		Pattern sb2ShowPattern = Pattern
+				.compile(commandAbstractor
+						.getPreferenceValue(SB2PreferenceConstants.SB2_SB2_SHOW_PATH_OUTPUT_PATTERN));
+
+		for (String line : lines) {
+			Matcher matcher = sb2ShowPattern.matcher(line);
+			if (matcher.matches()) {
+				String toPath = matcher.group(2);
+				// workaround buggy output
+				if (toPath.startsWith("//"))
+					toPath = toPath.substring(1);
+				result.put(new Path(matcher.group(1)), new Path(toPath));
+			}
+		}
+
+		return result;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2FileSystemMapping.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2FileSystemMapping.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2FileSystemMapping.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,84 @@
+/**
+ * (c) 2008 Nokia
+ */
+package org.maemo.esbox.internal.scratchbox.sb2.core;
+
+import com.nokia.cpp.internal.api.utils.core.Pair;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.internal.api.common.core.machine.FileSystemMapping;
+import org.maemo.mica.internal.api.common.core.machine.IFileSystemMappingImpl;
+
+import java.util.*;
+
+/**
+ * Represent the mappings from the machine to a Scratchbox 2 target running on
+ * the machine. This represents the direct mappings with all softlinks resolved.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2FileSystemMapping extends FileSystemMapping implements
+		IFileSystemMappingImpl {
+	/**
+	 * Construct with default path canonicalizers and add mappings for paths
+	 * known to be mapped.
+	 * 
+	 * @param targetRoot
+	 * @param target
+	 */
+	public Scratchbox2FileSystemMapping(IScratchboxSDKTarget sdkTarget,
+			IPath scratchboxBase, String target, String user) {
+
+		super(FileSystemMapping.getMachineCanonicalizer(true),
+				FileSystemMapping.getMachineCanonicalizer(true));
+
+		List<Pair<IPath, IPath>> mappings = getHostToTargetRootMappings();
+		mappings.clear();
+
+		// directories we're interested in
+		String[] topLevelDirs = { "/dev", "/home", "/proc", "/sys", "/targets",
+				"/bin", "/boot", "/cdrom", "/etc", "/floppy", "/initrd",
+				"/lib", "/media", "/mnt", "/opt", "/root", "/sbin", "/srv",
+				"/usr",
+				"/var",
+
+				// things get messier, so be more specific
+				"/var/cache/apt", "/usr/include", "/usr/lib",
+				"/usr/local/include", "/usr/local/lib", "/usr/X11R6",
+				"/usr/local", "/home/user", };
+
+		List<IPath> topLevelPaths = new ArrayList<IPath>();
+		topLevelPaths.add(new Path("/"));
+		for (String topLevelDir : topLevelDirs) {
+			topLevelPaths.add(new Path(topLevelDir));
+		}
+
+		Map<IPath, IPath> pathMapping = null;
+		try {
+			pathMapping = Scratchbox2SDK.getSb2PathMapping(sdkTarget,
+					topLevelPaths);
+			// pathMapping = ScratchboxFacade.getInstance().getSb2PathMapping(
+			// sdkTarget, topLevelPaths);
+		} catch (MicaException e) {
+			Activator.getErrorLogger().logError(
+					"Unable to map Scratchbox 2 paths", e);
+			return;
+		}
+
+		for (Map.Entry<IPath, IPath> entry : pathMapping.entrySet()) {
+			map(mappings, entry.getValue(), entry.getKey());
+		}
+
+		setHostToTargetRootMappings(mappings);
+	}
+
+	private void map(List<Pair<IPath, IPath>> mappings, IPath from, IPath to) {
+		mappings.add(new Pair<IPath, IPath>(from, to));
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDK.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDK.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDK.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,523 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API. Implementation from ScratchboxFacade 
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.core;
+
+import org.eclipse.core.runtime.*;
+import org.maemo.esbox.internal.api.scratchbox.core.sdk.*;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.esbox.internal.scratchbox.sb2.command.*;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
+import org.maemo.esbox.scratchbox.sb2.sdk.IScratchbox2SDK;
+import org.maemo.esbox.scratchbox.sb2.sdk.MaemoRootstrap;
+import org.maemo.mica.common.core.CorePreferenceConstants;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineUtils;
+import org.maemo.mica.common.core.sdk.*;
+import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
+import org.maemo.mica.internal.api.common.core.sdk.BaseSDKPlatform;
+
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author baranov
+ * 
+ */
+public class Scratchbox2SDK extends AbstractScratchboxSDK implements
+		IScratchbox2SDK {
+
+	private static final IPath ROOT_PATH = new Path("/");
+	private static Pattern TARGET_PLATFORM_VERSION_ARCHITECTURE_PATTERN = Pattern
+			.compile("([a-zA-Z_]+)(\\d+)_([a-zA-Z]+)");
+
+	private static final String SB2_MACHINE = "sb2_machine";
+	private static final String SB2_VERSION = "sb2_version";
+
+	public Scratchbox2SDK(IMachine machine, String version,
+			IPreferenceProvider prefProvider) {
+		super(machine, version, "Scratchbox 2", SB2_MACHINE, SB2_VERSION,
+				"sb2_targets", 2);
+		this.prefProvider = prefProvider;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.AbstractScratchboxSDK#refresh()
+	 */
+	public void refresh() {
+		super.refresh();
+		List<String> targetNames;
+		try {
+			targetNames = getTargets();
+		} catch (MicaException e) {
+			Activator.getErrorLogger().logError("Could not refresh targets", e);
+			return;
+		}
+		List<ISDKTarget> newTargets = new ArrayList<ISDKTarget>();
+		for (String target : targetNames) {
+			// ignore this one, left behind by errant rootstrap installations
+			if (target.equals("libtool_build"))
+				continue;
+			IPath config = getScratchbox2ConfigDirectory();
+			IPath sb2BasePath = config.append(target);
+			Scratchbox2SDKTarget sdkTarget = new Scratchbox2SDKTarget(this,
+					getPlatform(target), getArchitecture(target), target,
+					sb2BasePath);
+			newTargets.add(sdkTarget);
+
+			try {
+				IPath sb2RootstrapPath = getMaemoRootstrapPath(sdkTarget);
+				sdkTarget.setRootstrapPath(sb2RootstrapPath);
+			} catch (MicaException e) {
+				Activator.getErrorLogger().logError(null, e);
+			}
+
+		}
+		this.targets = newTargets;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getTargets()
+	 */
+	public List<String> getTargets() throws MicaException {
+		CacheUtils.getInstance().ensureCurrentMachine(SB_MACHINE, this.getMachine());
+
+		String[] targetsArray = (String[]) CacheUtils.getInstance()
+				.getCachedValue(SB_TARGETS);
+		if (targetsArray != null)
+			return Arrays.asList(targetsArray);
+
+		ListTargetsCommand listTargetsCommand = new ListTargetsCommand(
+				getCommandAbstractor());
+		List<String> targets = listTargetsCommand
+				.performCommand(new ArrayList<String>());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS,
+				(String[]) targets.toArray(new String[targets.size()]));
+
+		return targets;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.AbstractScratchboxSDK#getCommandAbstractor
+	 * ()
+	 */
+	public ICommandAbstractor getCommandAbstractor() throws MicaException {
+		return getSb2WrappedAbstractor(super.getCommandAbstractor(), this
+				.getMachine());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK#
+	 * getScratchbox2ConfigDirectory()
+	 */
+	public IPath getScratchbox2ConfigDirectory() {
+		String userName = prefProvider
+				.getPreferenceValue(CorePreferenceConstants.USER);
+		if (userName.length() == 0)
+			userName = "ubuntu";
+		return new Path("home").append(userName).append(".scratchbox2")
+				.makeAbsolute();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#createTarget(java.lang
+	 * .String, java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public boolean createTarget(String targetName, String compiler,
+			String devkits, String cputransp) throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(compiler);
+		params.add(cputransp);
+
+		CreateTargetSb2Command createTargetCommand = new CreateTargetSb2Command(
+				this, getCommandAbstractor());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+
+		return (Boolean) createTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getCompilers()
+	 */
+	public List<String> getCompilers() throws MicaException {
+		ListCompilersSb2Command listCompilersCommand = new ListCompilersSb2Command(
+				getCommandAbstractor());
+		return listCompilersCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getCputransp()
+	 */
+	public List<String> getCputransp() throws MicaException {
+		ListCputranspSb2Command listCputranspCommand = new ListCputranspSb2Command(
+				getCommandAbstractor());
+		return listCputranspCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#getCurrentTarget()
+	 */
+	public String getCurrentTarget() throws MicaException {
+		GetCurrentTargetSb2Command getCurrentTargetCommand = new GetCurrentTargetSb2Command(
+				getCommandAbstractor());
+		return (String) getCurrentTargetCommand
+				.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.IScratchboxSDK#removeTarget(java.lang
+	 * .String)
+	 */
+	public boolean removeTarget(String targetName) throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+
+		RemoveTargetSb2Command removeTargetCommand;
+		removeTargetCommand = new RemoveTargetSb2Command(this,
+				getCommandAbstractor());
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+		CacheUtils.getInstance().setCachedValue(
+				SB2_TARGET_TO_PATH_MAPPINGS_MAP, null);
+		CacheUtils.getInstance().setCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP,
+				null);
+		return (Boolean) removeTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDK#getSDKRoot()
+	 */
+	public IPath getSDKRoot() {
+		return ROOT_PATH;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.maemosdk.core.sdk.
+	 * IScratchboxSDKPlatformArchitectureProvider
+	 * #getArchitecture(java.lang.String)
+	 */
+	public String getArchitecture(String target) {
+		// convention says this is the part of the target after the underscore
+		Matcher matcher = TARGET_PLATFORM_VERSION_ARCHITECTURE_PATTERN
+				.matcher(target);
+		if (matcher.matches()) {
+			return matcher.group(3).toUpperCase();
+		} else {
+			return IScratchboxSDKTarget.ARCHITECTURE_UNKNOWN;
+		}
+	}
+
+	public ISDKPlatform getPlatform(String target) {
+		// convention says this is the part of the target before the underscore,
+		// minus a version.
+		Matcher matcher = TARGET_PLATFORM_VERSION_ARCHITECTURE_PATTERN
+				.matcher(target);
+		if (matcher.matches()) {
+			String name = matcher.group(1);
+			String platformName = name.substring(0, 1).toUpperCase()
+					+ name.substring(1).toLowerCase();
+			String versionInfo = matcher.group(2);
+			String version = ISDKPlatform.VERSION_UNKNOWN;
+			if (versionInfo.length() == 2)
+				version = versionInfo.substring(0, 1) + "."
+						+ versionInfo.substring(1, 2);
+			return new BaseSDKPlatform(platformName, version);
+		} else {
+			return new BaseSDKPlatform(ISDKPlatform.NAME_UNKNOWN,
+					ISDKPlatform.VERSION_UNKNOWN);
+		}
+	}
+
+	/**
+	 * Get the names of rootstraps already installed. This may inclue those that
+	 * do not have targets associated.
+	 * 
+	 * @param sdk
+	 *            the SDK to check
+	 * @return List, never null
+	 * @throws MicaException
+	 */
+	public synchronized List<String> getInstalledMaemoRootstraps()
+			throws MicaException {
+		ListInstalledMaemoRootstrapsSb2Command command = new ListInstalledMaemoRootstrapsSb2Command(
+				MachineUtils.getHostCommandAbstractor(this.getMachine()));
+		return command.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.sb2.core.IScratchbox2SDK#getAvailableMaemoRootstraps
+	 * (org.maemo.mica.common.core.machine.IMachine)
+	 */
+	public List<MaemoRootstrap> getAvailableMaemoRootstraps(IMachine machine)
+			throws MicaException {
+		ListAvailableMaemoRootstrapsSb2Command command = new ListAvailableMaemoRootstrapsSb2Command(
+				MachineUtils.getHostCommandAbstractor(machine));
+		return command.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.sb2.core.IScratchbox2SDK#createRootstrapTarget
+	 * (java.lang.String, boolean, boolean,
+	 * org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public boolean createRootstrapTarget(String targetName,
+			boolean useHostTools, boolean force, IProgressMonitor monitor)
+			throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(Boolean.toString(useHostTools));
+		params.add(Boolean.toString(force));
+
+		CreateMaemoRootstrapSb2Command createTargetCommand = new CreateMaemoRootstrapSb2Command(
+				this, getCommandAbstractor(), monitor);
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+
+		return createTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.sb2.core.IScratchbox2SDK#removeRootstrap(java
+	 * .lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public boolean removeRootstrap(String targetName, boolean force,
+			IProgressMonitor monitor) throws MicaException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(Boolean.toString(force));
+
+		RemoveMaemoRootstrapSb2Command removeTargetCommand = new RemoveMaemoRootstrapSb2Command(
+				getCommandAbstractor(), monitor);
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+		CacheUtils.getInstance().setCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP,
+				null);
+		CacheUtils.getInstance().setCachedValue(
+				SB2_TARGET_TO_PATH_MAPPINGS_MAP, null);
+
+		return removeTargetCommand.performCommand(params);
+	}
+
+	/**
+	 * Invoke sb2-show path on the given path(s) to return the mappings.
+	 * 
+	 * @param hostPaths
+	 *            array of paths to map
+	 * @return map of resolved host paths to target paths
+	 * @throws MicaException
+	 */
+	public static synchronized Map<IPath, IPath> getSb2PathMapping(
+			IScratchboxSDKTarget sdkTarget, List<IPath> hostPaths)
+			throws MicaException {
+		// find cached value
+		CacheUtils.getInstance().ensureCurrentMachine(SB2_MACHINE, sdkTarget.getSDK()
+				.getMachine());
+		Map<String, Map<String, String>> targetToPathMappingsMap = null;
+		Map<String, String> storedPathMappings = null;
+		targetToPathMappingsMap = (Map<String, Map<String, String>>) CacheUtils
+				.getInstance().getCachedValue(SB2_TARGET_TO_PATH_MAPPINGS_MAP);
+		if (targetToPathMappingsMap != null) {
+			storedPathMappings = targetToPathMappingsMap.get(sdkTarget
+					.getName());
+		}
+
+		Map<IPath, IPath> returnedPathMappings = new HashMap<IPath, IPath>();
+
+		// locate entries known to the cache
+		List<IPath> needToLookupHostPaths;
+		if (storedPathMappings != null) {
+			needToLookupHostPaths = new ArrayList<IPath>();
+			for (IPath hostPath : hostPaths) {
+				String targetPath = storedPathMappings.get(hostPath
+						.toPortableString());
+				if (targetPath != null) {
+					returnedPathMappings.put(hostPath, new Path(targetPath));
+				} else {
+					needToLookupHostPaths.add(hostPath);
+				}
+			}
+		} else {
+			needToLookupHostPaths = hostPaths;
+		}
+
+		if (needToLookupHostPaths.size() == 0) {
+			return returnedPathMappings;
+		}
+
+		// do the hard work for the paths not covered by the cache
+		ShowPathMappingSb2Command command = new ShowPathMappingSb2Command(
+				((Scratchbox2SDKTarget)sdkTarget).getCommandAbstractor());
+		List<String> paths = new ArrayList<String>(needToLookupHostPaths.size());
+		for (IPath path : needToLookupHostPaths) {
+			paths.add(path.toPortableString());
+		}
+
+		Map<IPath, IPath> newPathMappings = (Map<IPath, IPath>) command
+				.performCommand(paths);
+		returnedPathMappings.putAll(newPathMappings);
+
+		// update cache
+		if (storedPathMappings == null) {
+			storedPathMappings = new HashMap<String, String>();
+		}
+		for (Map.Entry<IPath, IPath> entry : newPathMappings.entrySet()) {
+			storedPathMappings.put(entry.getKey().toPortableString(), entry
+					.getValue().toPortableString());
+		}
+		if (targetToPathMappingsMap == null) {
+			targetToPathMappingsMap = new HashMap<String, Map<String, String>>();
+		}
+		targetToPathMappingsMap.put(sdkTarget.getName(), storedPathMappings);
+
+		CacheUtils.getInstance().setCachedValue(
+				SB2_TARGET_TO_PATH_MAPPINGS_MAP, targetToPathMappingsMap);
+
+		return returnedPathMappings;
+	}
+
+	/**
+	 * Return the current version of Scratchbox 2
+	 * 
+	 * @return the current version of Scratchbox 2.
+	 * @throws MicaException
+	 *             if any problem related to Scratchbox communication occurs,
+	 *             including no scratchbox 2 detected
+	 */
+	public static synchronized String getCurrentSboxVersion(IMachine machine)
+			throws MicaException {
+		// find cached value
+		CacheUtils.getInstance().ensureCurrentMachine(SB2_MACHINE, machine);
+		String version = (String) CacheUtils.getInstance().getCachedValue(
+				SB2_VERSION);
+		if (version != null)
+			return version;
+
+		// do the hard work
+		MachineUtils.acquireMachine(machine);
+		ICommandAbstractor commandAbstractor = MachineUtils
+				.getHostCommandAbstractor(machine);
+		commandAbstractor = getSb2WrappedAbstractor(commandAbstractor, machine);
+		GetVersionScratchboxCommand getVersionCommand = new GetVersionScratchboxCommand(
+				commandAbstractor);
+
+		String currentVersion = getVersionCommand
+				.performCommand(new ArrayList<String>());
+		// remember cached value
+		CacheUtils.getInstance().setCachedValue(SB2_VERSION, currentVersion);
+
+		return currentVersion;
+	}
+
+	/**
+	 * Get the path where a maemo rootstrap is installed
+	 * 
+	 * @param scratchbox2SDKTarget
+	 * @return path of rootstrap
+	 * @throws MicaException
+	 *             if not located
+	 */
+	private synchronized IPath getMaemoRootstrapPath(
+			Scratchbox2SDKTarget sdkTarget) throws MicaException {
+		// find cached value
+		CacheUtils.getInstance().ensureCurrentMachine(SB_MACHINE, sdkTarget.getSDK()
+				.getMachine());
+		Map<String, String> targetToRootstrapMap = null;
+		targetToRootstrapMap = (Map<String, String>) CacheUtils.getInstance()
+				.getCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP);
+		if (targetToRootstrapMap != null) {
+			String rootstrap = targetToRootstrapMap.get(sdkTarget.getName());
+			if (rootstrap != null) {
+				return new Path(rootstrap);
+			}
+		}
+
+		// do the hard work
+		GetMaemoRootstrapLocationCommand command = new GetMaemoRootstrapLocationCommand(
+				getCommandAbstractor(), sdkTarget);
+		IPath rootstrapPath;
+
+		// be sure to record something in the cache for broken targets so
+		// we don't keep asking all the time
+		MicaException caughtException = null;
+		try {
+			rootstrapPath = (IPath) command.performCommand(EMPTY_ARGS);
+		} catch (MicaException e) {
+			rootstrapPath = Path.EMPTY;
+			caughtException = e;
+		}
+
+		// store cached value
+		if (targetToRootstrapMap == null)
+			targetToRootstrapMap = new HashMap<String, String>();
+		targetToRootstrapMap.put(sdkTarget.getName(), rootstrapPath
+				.toPortableString());
+		CacheUtils.getInstance().setCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP,
+				targetToRootstrapMap);
+
+		if (caughtException != null)
+			throw caughtException;
+
+		return rootstrapPath;
+	}
+
+	/**
+	 * Get a command abstractor that updates the PATH if sb2 tools are not on
+	 * the path.
+	 * 
+	 * @param commandAbstractor
+	 * @param machine
+	 * @return
+	 */
+	private static ICommandAbstractor getSb2WrappedAbstractor(
+			ICommandAbstractor commandAbstractor, IMachine machine) {
+		// XXX: the default path should be provided some other way
+		return wrapCommandAbstractorForSDK(commandAbstractor, machine, "sb2",
+				"/usr/bin");
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API. Implementation from ScratchboxFacade 
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.core;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.internal.api.scratchbox.core.sdk.AbstractScratchboxSDKTarget;
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.internal.scratchbox.sb2.command.GetGdbQemuCommandPatternCommand;
+import org.maemo.esbox.internal.scratchbox.sb2.launcher.Scratchbox2ProcessLauncherFactory;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
+import org.maemo.mica.common.core.CorePreferenceConstants;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.IProcessLauncherFactory;
+import org.maemo.mica.common.core.sdk.ISDKPlatform;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author baranov
+ * 
+ */
+public class Scratchbox2SDKTarget extends AbstractScratchboxSDKTarget {
+	private IPath targetRoot;
+	private IPath rootstrapRoot;
+
+	public Scratchbox2SDKTarget(Scratchbox2SDK sdk, ISDKPlatform platform,
+			String architecture, String target, IPath targetRoot) {
+		super(sdk, platform, architecture, target);
+		if (targetRoot == null)
+			throw new IllegalArgumentException();
+		this.targetRoot = targetRoot;
+		init(new Scratchbox2FileSystemMapping(this, targetRoot, target, sdk
+				.getPreferenceValue(CorePreferenceConstants.USER))
+		// ,new AptPackageManager(this)
+		);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#
+	 * getProcessLauncherFactoryForInstall()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactoryForInstall() {
+		// install mode needs to be a different mapping and also run as root
+		return new Scratchbox2ProcessLauncherFactory(this,
+				SB2PreferenceConstants.SB2_INSTALL_MAPPING_MODE, true);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.maemosdk.core.sdk.IScratchboxSDKTarget#getRootstrapPath()
+	 */
+	public IPath getRootstrapPath() {
+		return rootstrapRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDKTarget#getProcessLauncherFactory()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactory() {
+		// default is build mode
+		return new Scratchbox2ProcessLauncherFactory(this,
+				SB2PreferenceConstants.SB2_MAPPING_MODE, false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDKTarget#getSDKTargetRoot()
+	 */
+	public IPath getSDKTargetRoot() {
+		return targetRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.internal.api.common.core.sdk.BaseSDKTarget#getArchitecture()
+	 */
+	public String getArchitecture() {
+		// sb2 doesn't YET ship an x86 emulator
+		return IScratchboxSDKTarget.ARCHITECTURE_ARMEL;
+	}
+
+	/**
+	 * Get the command template for launching qemu under gdb with this target
+	 * 
+	 * @param sdkTarget
+	 * @param architecture
+	 *            one of {@link IScratchboxSDKTarget#ARCHITECTURE_ARMEL} or
+	 *            {@link IScratchboxSDKTarget#ARCHITECTURE_X86}; usually from
+	 *            sdkTarget.getArchitecture()
+	 * @return String or null if no cputransp used or not using qemu
+	 */
+	public synchronized String getGdbQemuCommandPattern(String architecture)
+			throws MicaException {
+		// ScratchboxSDK2 sdk = (ScratchboxSDK2)this.getSDK();
+		GetGdbQemuCommandPatternCommand command = new GetGdbQemuCommandPatternCommand(
+				this, this.getCommandAbstractor());
+		List<String> arguments = new ArrayList<String>(1);
+		arguments.add(architecture);
+		return command.performCommand(arguments);
+	}
+
+	/** Not API! The targets should be refreshed from ISDK#refresh() */
+	void setRootstrapPath(IPath rootstrapPath) {
+		this.rootstrapRoot = rootstrapPath;
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2EnvironmentProvider.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2EnvironmentProvider.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2EnvironmentProvider.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.launcher;
+
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils.Results;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.common.core.IStandardEnvironmentProvider;
+
+import java.util.*;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2EnvironmentProvider implements
+		IStandardEnvironmentProvider {
+	public static Map<ISDKTarget, Properties> cachedStdEnvMap = new HashMap<ISDKTarget, Properties>();
+	private final ISDKTarget sdkTarget;
+
+	/**
+	 * @param sdkTarget
+	 */
+	public Scratchbox2EnvironmentProvider(ISDKTarget sdkTarget) {
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * flushRawEnvironment()
+	 */
+	public void flushRawEnvironment() {
+		cachedStdEnvMap.remove(sdkTarget);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * getRawEnvironment()
+	 */
+	public Properties getRawEnvironment() {
+		Properties standardEnv = cachedStdEnvMap.get(sdkTarget);
+		if (standardEnv == null) {
+			// gather arguments by querying a typical shell launched in POSIX
+			// mode (sh instead of bash)
+			Scratchbox2ProcessLauncher launcher = new Scratchbox2ProcessLauncher(
+					sdkTarget, null, CommandLineArguments.createFromVarArgs(
+							"sh", "-c", "set"), null,
+					SB2PreferenceConstants.SB2_MAPPING_MODE, false);
+
+			try {
+				Results results = ProcessLauncherUtils
+						.launchAndReadStandardStreams(launcher, null);
+				standardEnv = EnvironmentProperties
+						.createFromShellEnvDump(results.stdout);
+			} catch (MicaException e) {
+				Activator
+						.getErrorLogger()
+						.logError(
+								"Failed to read scratchbox environment; using system environment",
+								e);
+				standardEnv = sdkTarget.getSDK().getMachine()
+						.getStandardEnvironment();
+			}
+
+			cachedStdEnvMap.put(sdkTarget, standardEnv);
+		}
+		return standardEnv;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncher.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncher.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncher.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.launcher;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.process.*;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+
+import java.util.List;
+
+/**
+ * For SB 2, launching is easy and follows the same pattern as a normal program
+ * invocation.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2ProcessLauncher extends BaseSDKTargetProcessLauncher implements
+		IProcessLauncher {
+
+	private ISDKTarget sdkTarget;
+
+	public Scratchbox2ProcessLauncher(ISDKTarget sdkTarget,
+			IPath workingDirectory, List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock, String modeKey,
+			boolean runAsRoot) {
+		super(encodeArgumentArray(sdkTarget, cmdLine, modeKey),
+				environmentModifierBlock, workingDirectory,
+				sdkTarget);
+		if (runAsRoot) {
+			getLaunchCommandArguments().add(0, "sudo");
+		}
+		if (sdkTarget == null)
+			throw new IllegalArgumentException();
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.internal.common.core.BaseProcessLauncher#getLaunchInfoPrefix()
+	 */
+	@Override
+	protected String getLaunchInfoPrefix() {
+		return sdkTarget + " ";
+	}
+
+	private static List<String> encodeArgumentArray(ISDKTarget sdkTarget,
+			List<String> cmdLine, String modeKey) {
+
+		// Encode the launch command by replacing the arguments
+		// representing template arguments with the actual values.
+		//
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+
+		substitutor.define("TARGET", sdkTarget.getName());
+		substitutor.define("COMMAND", cmdLine.get(0));
+		substitutor.define("ARGS", CommandLineArguments.toCommandLine(cmdLine
+				.subList(1, cmdLine.size())));
+
+		String level = sdkTarget
+				.getPreferenceValue(SB2PreferenceConstants.SB2_LOG_LEVEL);
+		if (level.length() > 0) {
+			substitutor.define("LOG_OPTION", "-L " + level);
+		} else {
+			substitutor.define("LOG_OPTION", "");
+		}
+
+		String mapMode = sdkTarget.getPreferenceValue(modeKey);
+		substitutor.define("MAPPING_MODE", mapMode);
+
+		// get the Scratchbox invocation pattern
+		String commandPattern = sdkTarget
+				.getPreferenceValue(SB2PreferenceConstants.SB2_EXEC_COMMAND);
+
+		// replace variables
+		commandPattern = substitutor.substitute(commandPattern);
+
+		List<String> commandArgs = CommandLineArguments
+				.createFromCommandLine(commandPattern);
+		return commandArgs;
+	}
+
+	@Override
+	protected void setupForLaunch() throws MicaException {
+		// nothing
+		super.setupForLaunch();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.internal.common.core.BaseProcessLauncher#doCreateProcess()
+	 */
+	@Override
+	protected Process doCreateProcess() throws Exception {
+		return sdkTarget.getSDK().getMachine().createProcess(
+				getLaunchCurrentWorkingDirectory(),
+				getLaunchCommandArguments(),
+				getLaunchEnvironmentModifierBlock(), isUsePTY());
+	}
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncherFactory.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncherFactory.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/launcher/Scratchbox2ProcessLauncherFactory.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.launcher;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.process.IProcessLauncher;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.common.core.BaseProcessLauncherFactory;
+
+import java.util.List;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2ProcessLauncherFactory extends
+		BaseProcessLauncherFactory {
+
+	protected ISDKTarget sdkTarget;
+	private String mappingModeKey;
+	private final boolean runAsRoot;
+
+	/**
+	 * Create a factory and specify whether it is creating commands in build
+	 * mode (sb2 -m maemo) or installation mode (sb2 -e)
+	 * 
+	 * @param sdkTarget
+	 * @param mappingModeKey
+	 *            one of SB2PreferenceConstants.MAPPING_MODE or
+	 *            SB2PreferenceConstants.INSTALL_MAPPING_MODE
+	 * @param isBuildMode
+	 *            true: build mode, false: installation mode
+	 */
+	public Scratchbox2ProcessLauncherFactory(ISDKTarget sdkTarget,
+			String mappingModeKey, boolean runAsRoot) {
+		super(new Scratchbox2EnvironmentProvider(sdkTarget), false);
+		if (sdkTarget == null)
+			throw new IllegalArgumentException();
+		this.sdkTarget = sdkTarget;
+		this.mappingModeKey = mappingModeKey;
+		this.runAsRoot = runAsRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.common.core.IProcessLauncherFactory#createProcessLauncher(org
+	 * .eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath,
+	 * org.maemo.mica.common.core.List<String>, java.util.Properties)
+	 */
+	protected IProcessLauncher doCreateProcessLauncher(IPath workingDirectory,
+			List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock) {
+
+		return new Scratchbox2ProcessLauncher(sdkTarget, workingDirectory,
+				cmdLine, environmentModifierBlock, mappingModeKey, runAsRoot);
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.provider;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.maemo.esbox.internal.api.scratchbox.core.sdk.CacheUtils;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.esbox.internal.scratchbox.sb2.core.Scratchbox2SDK;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.mica.common.core.*;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
+import org.maemo.mica.common.core.sdk.*;
+import org.maemo.mica.internal.api.common.core.sdk.UserAwarePreferenceProviderWrapper;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This implementation of the SDK provider searches for SB2 targets using the
+ * 'sb2-config -l' command. If any aspect of SB2 communication fails, we assume
+ * SB2 is not installed.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2SDKProvider implements ISDKProvider {
+
+	// this may need to be bumped once an official release is made
+	private static final String SCRATCHBOX_VERSION_PATTERN = "1\\.99\\..*"; //$NON-NLS-1$
+
+	/**
+	 * 
+	 */
+	public Scratchbox2SDKProvider() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.mica.common.core.sdk.ISDKProvider#createSDKs()
+	 */
+	public List<ISDK> createSDKs() throws MicaException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		List<ISDK> sdks = new ArrayList<ISDK>();
+		for (IMachine machine : MachineRegistry.getInstance()
+				.getBuildMachines()) {
+			// will never find sbox on host (right?!)
+			if (machine.getOS().equals(Platform.OS_WIN32))
+				continue;
+
+			try {
+				IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
+						CorePreferenceManager.getInstance()
+								.getPreferenceProvider(), machine);
+				Scratchbox2SDK sdk = getMachineSDK(prefProvider, machine);
+				if (sdk != null) {
+					sdks.add(sdk);
+					sdk.refresh();
+				}
+			} catch (ScratchboxException e) {
+				logger.log(IStatus.INFO,
+						"Problem scanning Scratchbox 2 installation", e);
+			}
+		}
+
+		CacheUtils.getInstance().saveCachedData();
+
+		return sdks;
+	}
+
+	/**
+	 * @param logger
+	 * @param prefProvider
+	 * @param sdks
+	 * @return
+	 * @throws ScratchboxException
+	 */
+	private Scratchbox2SDK getMachineSDK(IPreferenceProvider prefProvider,
+			IMachine machine) throws MicaException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		// only support one Scratchbox 2 installation
+		String version = Scratchbox2SDK.getCurrentSboxVersion(machine);
+		if (version == null) {
+			// no scratchbox?
+			return null;
+		}
+
+		if (!version.matches(SCRATCHBOX_VERSION_PATTERN)) {
+			logger
+					.logError(
+							MessageFormat
+									.format(
+											"Only Scratchbox 2 version 1.99.x is supported (detected {0}); disabling Scratchbox 2 support",
+											version), null);
+			return null;
+		}
+
+		Scratchbox2SDK sdk = new Scratchbox2SDK(machine, version, prefProvider);
+
+		return sdk;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.ui.adapters;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.internal.api.scratchbox.ui.adapters.MaemoScratchboxSDKManageTargetAdapterBase;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.esbox.internal.scratchbox.sb2.ui.wizard.NewScratchbox2TargetWizard;
+import org.maemo.esbox.scratchbox.sb2.sdk.IScratchbox2SDK;
+import org.maemo.esbox.scratchbox.sb2.sdk.MaemoRootstrap;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter;
+import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.maemosdk.ui.adapters.MaemoTargetRemover;
+
+import java.util.List;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoScratchbox2SDKManageTargetAdapter extends
+		MaemoScratchboxSDKManageTargetAdapterBase implements
+		ISDKManageTargetAdapter {
+
+	private final IScratchbox2SDK sdk;
+
+	/**
+	 * @param sdk
+	 */
+	public MaemoScratchbox2SDKManageTargetAdapter(IScratchbox2SDK sdk) {
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter#installSDKTargets
+	 * (org.eclipse.swt.widgets.Shell, java.util.List)
+	 */
+	public IStatus installSDKTargets(Shell shell, List<ISDKTarget> installed) {
+		NewScratchbox2TargetWizard targetWizard;
+
+		targetWizard = new NewScratchbox2TargetWizard(sdk);
+		WizardDialog dlg = new WizardDialog(shell, targetWizard);
+		if (dlg.open() == Dialog.OK) {
+			return Status.OK_STATUS;
+		}
+
+		return Policy.getCancelStatus(Activator.getDefault());
+	}
+
+	protected MaemoTargetRemover createTargetRemover(Shell shell,
+			ISDKTarget target, boolean deleteRootstrap) {
+		return new MaemoTargetRemover(shell, target, deleteRootstrap) {
+
+			
+			protected void doDeleteTargetRootstrap(IProgressMonitor monitor,
+					ISDK sdk) throws MicaException {
+				((IScratchbox2SDK) sdk).removeRootstrap(
+						sdkTarget.getName(), true, new SubProgressMonitor(
+								monitor, 1));
+			};
+			
+			/* (non-Javadoc)
+			 * @see org.maemo.mica.internal.api.maemosdk.ui.adapters.ESboxTargetRemover#doRemoveTarget(org.maemo.mica.common.core.sdk.ISDK, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+			 */
+			@Override
+			protected void doRemoveTarget(ISDK sdk, String targetName,
+					IProgressMonitor monitor) throws MicaException {
+				((IScratchbox2SDK) sdk).removeTarget(targetName);
+				monitor.worked(1);
+				
+			}
+		};
+	}
+
+	@Override
+	protected boolean isRootStrapUsed(ISDKTarget selectedTarget) {
+		{
+			boolean rootstrapUsed_ = false;
+			try {
+				// see if a rootstrap -- possibly disconnected from the target --
+				// exists
+				List<MaemoRootstrap> rootstraps = sdk
+						.getAvailableMaemoRootstraps(selectedTarget.getSDK()
+								.getMachine());
+				for (MaemoRootstrap rootstrap : rootstraps) {
+					if (rootstrap.getName().equals(selectedTarget.getName())) {
+						rootstrapUsed_ = true;
+						break;
+					}
+				}
+			} catch (MicaException e1) {
+				Activator.getErrorLogger().logError(
+						"Failure scanning maemo rootstraps", e1);
+			}
+			return rootstrapUsed_;
+		}
+	}
+	
+	
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapterFactory.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapterFactory.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapterFactory.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.ui.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.esbox.scratchbox.sb2.sdk.IScratchbox2SDK;
+import org.maemo.mica.common.core.adapters.ISDKManageTargetAdapter;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoScratchbox2SDKManageTargetAdapterFactory implements IAdapterFactory {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
+	 * java.lang.Class)
+	 */
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(ISDKManageTargetAdapter.class)) {
+			if (adaptableObject instanceof IScratchbox2SDK) {
+				return new MaemoScratchbox2SDKManageTargetAdapter(
+						(IScratchbox2SDK) adaptableObject);
+			}
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	public Class[] getAdapterList() {
+		return new Class[] { ISDKManageTargetAdapter.class };
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/preferences/Scratchbox2PreferencesPage.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/preferences/Scratchbox2PreferencesPage.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/preferences/Scratchbox2PreferencesPage.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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 implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.ui.preferences;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.maemo.esbox.internal.api.scratchbox.sb2.core.SB2PreferenceConstants;
+
+/**
+ * General preference page for scratchbox 2
+ * 
+ * @author eswartz
+ */
+public class Scratchbox2PreferencesPage extends FieldEditorPreferencePage
+		implements IWorkbenchPreferencePage {
+
+	/**
+	 * Field for build mapping mode
+	 */
+	private StringFieldEditor feSbox2BuildMappingMode = null;
+	/**
+	 * Field for install mapping mode
+	 */
+	private StringFieldEditor feSbox2InstallMappingMode = null;
+
+	/**
+	 * Field for log level
+	 */
+	private RadioGroupFieldEditor feSbox2LogLevel = null;
+
+	private StringFieldEditor feSbox2CommandLine;
+
+	/**
+	 * The constructor
+	 */
+	public Scratchbox2PreferencesPage() {
+		super(GRID);
+		setPreferenceStore(SB2PreferenceConstants.getPreferenceStore());
+		setDescription("Options configuring scratchbox 2");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
+	 * ()
+	 */
+	public void createFieldEditors() {
+
+		feSbox2BuildMappingMode = new StringFieldEditor(
+				SB2PreferenceConstants.SB2_MAPPING_MODE.toString(),
+				"Build mapping mode:", getFieldEditorParent());
+
+		feSbox2InstallMappingMode = new StringFieldEditor(
+				SB2PreferenceConstants.SB2_INSTALL_MAPPING_MODE.toString(),
+				"Install mapping mode:", getFieldEditorParent());
+
+		feSbox2LogLevel = new RadioGroupFieldEditor(
+				SB2PreferenceConstants.SB2_LOG_LEVEL.toString(),
+				"Logging level:", 1, new String[][] { { "none", "" }, //$NON-NLS-1$
+						{ "error", "error" }, //$NON-NLS-1$
+						{ "warning", "warning" }, //$NON-NLS-1$
+						{ "notice", "notice" }, //$NON-NLS-1$
+						{ "info", "info" }, //$NON-NLS-1$
+						{ "debug", "debug" }, //$NON-NLS-1$
+						{ "noise", "noise" }, //$NON-NLS-1$
+				}, getFieldEditorParent());
+
+		feSbox2CommandLine = new StringFieldEditor(
+				SB2PreferenceConstants.SB2_EXEC_COMMAND.toString(),
+				"Command template:", getFieldEditorParent());
+
+		// make this string manageable
+		GC gc = new GC(getFieldEditorParent().getShell());
+		GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+		gridData.widthHint = gc.getAdvanceWidth('m') * 32;
+		gc.dispose();
+		feSbox2CommandLine.getTextControl(getFieldEditorParent())
+				.setLayoutData(gridData);
+
+		addField(feSbox2BuildMappingMode);
+		addField(feSbox2InstallMappingMode);
+		addField(feSbox2LogLevel);
+		addField(feSbox2CommandLine);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	public void init(IWorkbench workbench) {
+		// Nothing to do
+	}
+
+}
\ No newline at end of file

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.ui.wizard;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Display;
+import org.maemo.esbox.scratchbox.sb2.sdk.IScratchbox2SDK;
+import org.maemo.esbox.scratchbox.sb2.sdk.MaemoRootstrap;
+import org.maemo.mica.common.core.MicaException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class provides installable rootstraps, descriptions, etc. from the
+ * result of 'maemo-rootstrap'.
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoRootstrapContentLabelProvider extends LabelProvider implements
+		ITreeContentProvider, ITableLabelProvider, IColorProvider,
+		IFontProvider {
+	static final int COLUMN_NAME = 0;
+	static final int COLUMN_ARCHITECTURE = 1;
+	static final int COLUMN_DESCRIPTION = 2;
+
+	public static Object NO_ROOTSTRAP = new Object();
+	public static Object LOADING_LABEL = new Object();
+
+	private boolean rootstrapsFetched;
+	// either MaemoRootstrap or NO_ROOTSTRAP
+	private List<Object> rootstraps;
+	private Thread rootstrapThread;
+	private final IScratchbox2SDK sdk;
+
+	public MaemoRootstrapContentLabelProvider(IScratchbox2SDK sdk) {
+		this.sdk = sdk;
+	}
+
+	public Object[] getElements(Object inputElement) {
+		if (!rootstrapsFetched) {
+			rootstraps = new ArrayList<Object>();
+			rootstraps.add(NO_ROOTSTRAP);
+			rootstraps.add(LOADING_LABEL);
+
+			if (rootstrapThread == null) {
+				rootstrapThread = new Thread(new Runnable() {
+
+					public void run() {
+						try {
+							List<MaemoRootstrap> realRootstraps = sdk
+									.getAvailableMaemoRootstraps(sdk
+											.getMachine());
+							synchronized (rootstraps) {
+								rootstraps.remove(1);
+								rootstraps.addAll(realRootstraps);
+							}
+						} catch (final MicaException e) {
+							Display.getDefault().syncExec(new Runnable() {
+
+								public void run() {
+									MessageDialog.openError(null,
+											"Rootstrap lookup failed",
+											"Error fetching rootstraps: check proxy settings?\n\n"
+													+ e.getMessage());
+								}
+
+							});
+						}
+						rootstrapsFetched = true;
+						rootstrapThread = null;
+						Display.getDefault().asyncExec(new Runnable() {
+
+							public void run() {
+								fireLabelProviderChanged(new LabelProviderChangedEvent(
+										MaemoRootstrapContentLabelProvider.this));
+							}
+
+						});
+					}
+
+				});
+				rootstrapThread.start();
+			}
+		}
+		synchronized (rootstraps) {
+			return rootstraps.toArray();
+		}
+	}
+
+	public Object[] getChildren(Object parentElement) {
+		return new Object[0];
+	}
+
+	public Object getParent(Object element) {
+		return null;
+	}
+
+	public boolean hasChildren(Object element) {
+		return false;
+	}
+
+	public void dispose() {
+
+	}
+
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		viewer.refresh();
+	}
+
+	public Image getColumnImage(Object element, int columnIndex) {
+		return null;
+	}
+
+	public String getColumnText(Object element, int columnIndex) {
+		switch (columnIndex) {
+		case COLUMN_NAME:
+			if (element == NO_ROOTSTRAP) {
+				return "Custom target";
+			} else if (element == LOADING_LABEL) {
+				return "Loading...";
+			} else {
+				return ((MaemoRootstrap) element).getName();
+			}
+
+		case COLUMN_ARCHITECTURE:
+			if (element == NO_ROOTSTRAP || element == LOADING_LABEL) {
+				return null;
+			}
+			return ((MaemoRootstrap) element).getArchitecture();
+
+		case COLUMN_DESCRIPTION:
+			if (element == NO_ROOTSTRAP) {
+				return "User-defined name and compiler, manually installed rootstrap";
+			} else if (element == LOADING_LABEL) {
+				return null;
+			} else {
+				return ((MaemoRootstrap) element).getDescription();
+			}
+		}
+		return null;
+	}
+
+	public Color getBackground(Object element) {
+		return null;
+	}
+
+	public Color getForeground(Object element) {
+		if (element == LOADING_LABEL)
+			return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
+		else
+			return null;
+	}
+
+	public Font getFont(Object element) {
+		if (element == LOADING_LABEL)
+			return JFaceResources.getFontRegistry().getItalic(
+					JFaceResources.DIALOG_FONT);
+		else
+			return null;
+	}
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/NewScratchbox2TargetWizard.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/NewScratchbox2TargetWizard.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/NewScratchbox2TargetWizard.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,402 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 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 (UFCG) - initial API and implementation
+ *    Carolina Nogueira de Souza (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb2.ui.wizard;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.*;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.*;
+import org.maemo.esbox.internal.api.scratchbox.ui.wizards.*;
+import org.maemo.esbox.internal.scratchbox.sb2.Activator;
+import org.maemo.esbox.scratchbox.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.scratchbox.sb2.sdk.IScratchbox2SDK;
+import org.maemo.esbox.scratchbox.sb2.sdk.MaemoRootstrap;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.ErrorLogger;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.internal.api.maemosdk.ui.wizards.sbrsh.SbrshConfigurationNFSServer;
+import org.maemo.mica.internal.api.maemosdk.ui.wizards.sbrsh.SbrshConfigurationTargetDevice;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.MessageFormat;
+import java.util.List;
+
+/**
+ * The target wizard provides a easy way to create a target for Scratchbox. As
+ * Scratchbox target configuration, the user can configure your target.
+ * 
+ */
+public class NewScratchbox2TargetWizard extends Wizard implements INewWizard {
+
+	protected WizardPage targetNamePage;
+	protected WizardPage compilerNamePage;
+	protected WizardPage cpuMethodName;
+	protected WizardPage sbrshConfigTargetDevice;
+	protected WizardPage sbrshConfigNFSServer;
+	protected IProject generatedProject;
+
+	private IScratchbox2SDK sdk;
+
+	private WizardPage maemoRootstrapPage;
+
+	protected ISDKTarget createdTarget;
+
+	private void initialize() {
+		setNeedsProgressMonitor(true);
+		setWindowTitle("New Scratchbox 2 Target");
+		ImageDescriptor image = Activator
+				.getImageDescriptor("./icons/full/wizban/newtarget_wiz.gif");
+		setDefaultPageImageDescriptor(image);
+		initPages();
+	}
+
+	/**
+	 * Constructs a new target wizard for the given SDK (from the target
+	 * configuration page)
+	 * 
+	 * @param sdk
+	 */
+	public NewScratchbox2TargetWizard(IScratchbox2SDK sdk) {
+		super();
+		this.sdk = sdk;
+		initialize();
+	}
+
+	/**
+	 * Inicializes the content of the pages.
+	 */
+	private void initPages() {
+		if (sdk != null) {
+			maemoRootstrapPage = new TargetWizardRootstrapSb2Page(sdk);
+			addPage(maemoRootstrapPage);
+			targetNamePage = TargetWizardPageFactory.getInstance()
+					.createNamePage(sdk);
+			addPage(targetNamePage);
+			compilerNamePage = TargetWizardPageFactory.getInstance()
+					.createCompilerPage(sdk);
+			addPage(compilerNamePage);
+			cpuMethodName = TargetWizardPageFactory.getInstance()
+					.createCPUMethod(sdk);
+			addPage(cpuMethodName);
+			sbrshConfigTargetDevice = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigDeviceTargetPage();
+			addPage(sbrshConfigTargetDevice);
+			sbrshConfigNFSServer = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigNFSSServer();
+			addPage(sbrshConfigNFSServer);
+		} else {
+			addPage(TargetWizardPageFactory.getInstance()
+					.createBadInstallationPage());
+		}
+	}
+
+	public boolean canFinish() {
+		if (sdk == null)
+			return false;
+
+		boolean nonCustomRootstrap = true;
+		if (maemoRootstrapPage != null)
+			nonCustomRootstrap = ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+					.canFinish();
+		boolean cpuPage = ((TargetWizardCPUMethod) cpuMethodName).canFinish();
+		boolean configDevice = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.canFinish();
+		boolean NFSServer = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.canFinish();
+		boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+
+		if (!sbrshConfigAccepted && (nonCustomRootstrap || cpuPage))
+			return true;
+		if (sbrshConfigAccepted && NFSServer && configDevice)
+			return true;
+
+		return false;
+	}
+
+	@Override
+	public IWizardPage getNextPage(IWizardPage page) {
+		if (page == maemoRootstrapPage) {
+			boolean nonCustomRootstrap = ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+					.canFinish();
+			if (nonCustomRootstrap)
+				return null;
+			else
+				return super.getNextPage(page);
+		}
+		if (page == cpuMethodName) {
+			boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+					.getSbrshConfigure();
+			if (!sbrshConfigAccepted) // user does not want to configure sbrsh
+				return null;
+			else
+				// user wants to configure sbrsh
+				return super.getNextPage(page);
+		}
+		return super.getNextPage(page);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
+	 */
+	public boolean performFinish() {
+		if (getRootstrap() != null) {
+			if (!setupTargetFromRootstrap())
+				return false;
+		} else {
+			if (!setupTargetFromScratch())
+				return false;
+		}
+
+		boolean sbrshConfigSelected = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+		if (sbrshConfigSelected) {
+			configureSbrshService();
+			showsDialog();
+		}
+
+		return true;
+	}
+
+	private boolean setupTargetFromScratch() {
+		String targetName;
+		// in this mode, construct a target from the user's settings
+		targetName = getTargetNameSelected();
+		String compilerName = getCompilerNameSelected();
+		String cpuMethod = getCputranspSelected();
+		try {
+			sdk.createTarget(targetName, compilerName, null, cpuMethod);
+			createdTarget = sdk.findSDKTarget(targetName);
+			return true;
+		} catch (MicaException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot get create target "
+					+ targetName, e);
+			return false;
+		}
+	}
+
+	private boolean setupTargetFromRootstrap() {
+		String targetName;
+		// in this mode, make a predefined target from a maemo rootstrap
+		targetName = getRootstrap().getName();
+		boolean create = true;
+
+		if (true) {
+			// see if the rootstrap (not necessarily the target) already exists,
+			// and ask user, in case this will overwrite their customizations
+			try {
+				List<String> installedRootstraps = sdk
+						.getInstalledMaemoRootstraps();
+				if (installedRootstraps.contains(targetName)) {
+					create = MessageDialog
+							.openConfirm(
+									getShell(),
+									"Reinstall rootstrap?",
+									MessageFormat
+											.format(
+													"The rootstrap ''{0}'' appears to be already installed, though it may be disconnected from scratchbox.\n\n"
+															+ "At this time, we can't recreate a target for this rootstrap, but "
+															+ "you could do it manually with 'sb2-init'.\n\n"
+															+ "Do you want to overwrite the rootstrap?",
+													targetName));
+				}
+			} catch (MicaException e) {
+				ErrorLogger errorLogger = Activator.getErrorLogger();
+				errorLogger.logError("Cannot detect installed rootstraps", e);
+			}
+		}
+
+		if (create) {
+			try {
+				createRootstrap(targetName, useHostTools());
+			} catch (MicaException e) {
+				ErrorLogger errorLogger = Activator.getErrorLogger();
+				errorLogger.logAndShowError(
+						"Cannot get create rootstrap target " + targetName, e);
+				return false;
+			}
+		}
+		return true;
+	}
+
+	private void createRootstrap(final String targetName,
+			final boolean useHostTools) throws ScratchboxException {
+		try {
+			getContainer().run(true, true, new IRunnableWithProgress() {
+
+				public void run(IProgressMonitor monitor)
+						throws InvocationTargetException, InterruptedException {
+					monitor.beginTask("Creating rootstrap",
+							IProgressMonitor.UNKNOWN);
+					try {
+						sdk.createRootstrapTarget(targetName, useHostTools,
+								true, new SubProgressMonitor(monitor, 1));
+						createdTarget = sdk.findSDKTarget(targetName);
+					} catch (MicaException e) {
+						throw new InvocationTargetException(e);
+					}
+					monitor.done();
+				}
+
+			});
+		} catch (InvocationTargetException e) {
+			if (e.getCause() instanceof ScratchboxException)
+				throw (ScratchboxException) e.getCause();
+			else
+				throw new ScratchboxException(e);
+		} catch (InterruptedException e) {
+			throw new ScratchboxException(e);
+		}
+	}
+
+	private MaemoRootstrap getRootstrap() {
+		return ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+				.getRootstrap();
+	}
+
+	private boolean useHostTools() {
+		return ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+				.useHostTools();
+	}
+
+	/**
+	 * Return the name of the target to be created.
+	 * 
+	 * @return the name of the target to be created.
+	 */
+	private String getTargetNameSelected() {
+		return ((TargetWizardNamePage) targetNamePage).getTextControl()
+				.getText();
+	}
+
+	/**
+	 * Return the compiler name of the target to be created.
+	 * 
+	 * @return the compiler name of the target to be created.
+	 */
+	private String getCompilerNameSelected() {
+		TableItem item = ((TargetWizardCompilerPage) compilerNamePage)
+				.getTableControl().getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Return the cputransp name of the target to be created.
+	 * 
+	 * @return the cputransp name of the target to be created.
+	 */
+	private String getCputranspSelected() {
+		TableItem item = ((TargetWizardCPUMethod) cpuMethodName).getTable()
+				.getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Configure sbrsh service.
+	 */
+	private void configureSbrshService() {
+		String targetName = getTargetNameSelected();
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceAddr();
+		String nfsHostname = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.getNFSHostname();
+
+		try {
+			sdk.configureSbrsh(targetName, deviceTargetAddr, nfsHostname);
+		} catch (MicaException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot configure sbrsh", e);
+		}
+	}
+
+	/**
+	 * Add user at access list of the sbrshd running at the target device.
+	 */
+	private void addUser() {
+		String deviceTargetIP = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String username = System.getProperty("user.name");
+		ErrorLogger errorLogger = Activator.getErrorLogger();
+
+		try {
+			String localAddr = getLocalIP();
+			sdk.addSbrshAccessList(deviceTargetIP, username, localAddr);
+		} catch (MicaException e) {
+			errorLogger
+					.logAndShowError(
+							"Cannot add user to the access list of sbrshd at the target device",
+							e);
+		} catch (UnknownHostException e) {
+			errorLogger.logAndShowError("Cannot get local IP address", e);
+		}
+	}
+
+	/**
+	 * Shows the dialog to ask the user if s/he wants to add his/herself to the
+	 * acess list of the sbrshd.
+	 */
+	private void showsDialog() {
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String text = "Do you want to add yourself to the access list of the sbrshd running on target device? \n";
+		text += "(This requires that "
+				+ deviceTargetAddr
+				+ " has ssh daemon running and sbrshd already installed, and that you have root access).";
+		boolean userAddedAtAccessList = MessageDialog.openQuestion(getShell(),
+				"Scratchbox Configuration", text);
+		if (userAddedAtAccessList) {
+			addUser();
+		}
+	}
+
+	/**
+	 * Get the local IP address.
+	 * 
+	 * @return the local IP address.
+	 * @throws UnknownHostException
+	 */
+	private String getLocalIP() throws UnknownHostException {
+		return InetAddress.getLocalHost().getHostAddress();
+	}
+
+	/**
+	 * We will accept the selection in the workbench to see if we can initialize
+	 * from it.
+	 * 
+	 * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+	 */
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+	}
+
+	/**
+	 * Get the target created. Only valid after wizard dialog completes.
+	 * 
+	 * @return newly created ISDKTarget or <code>null</code>
+	 */
+	public ISDKTarget getCreatedTarget() {
+		return createdTarget;
+	}
+
+}
\ No newline at end of file

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.scratchbox.sb2.ui.wizard;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+import org.maemo.esbox.internal.scratchbox.sb2.core.Scratchbox2SDK;
+import org.maemo.esbox.scratchbox.sb2.sdk.IScratchbox2SDK;
+import org.maemo.esbox.scratchbox.sb2.sdk.MaemoRootstrap;
+import org.maemo.mica.internal.api.maemosdk.ui.wizards.IValidatePage;
+
+/**
+ * This page allows the user to select a rootstrap (which defines the target
+ * name, compiler, devkits, and cpu method all at once) for use with sb2, or to
+ * explicitly select to configure all the aspects himself.
+ * 
+ * @author eswartz
+ * 
+ */
+public class TargetWizardRootstrapSb2Page extends WizardPage implements
+		IValidatePage {
+
+	protected TreeViewer rootstrapTargetViewer;
+	protected Text text;
+	/* private */IScratchbox2SDK sdk; // in case we use it later
+	protected Object selection;
+	private MaemoRootstrapContentLabelProvider provider;
+	private Button showExistingTargets;
+	private Button useHostTools;
+
+	/**
+	 * Constructs a NewTargetWizardNamePage.
+	 */
+	protected TargetWizardRootstrapSb2Page(IScratchbox2SDK sdk) {
+		super("Target Name");
+		this.sdk = sdk;
+		if (!(sdk instanceof Scratchbox2SDK)) {
+			throw new IllegalArgumentException(
+					"This page only expects a scratchbox 2 SDK");
+		}
+		setTitle("Select maemo SDK+ Rootstrap");
+		setDescription("Select the maemo rootstrap to install, or manually configure a target.");
+		setPageComplete(false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+	 * .Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		composite.setLayout(new GridLayout(1, false));
+
+		Label label = new Label(composite, SWT.LEFT);
+		label.setText("Select a rootstrap:");
+
+		rootstrapTargetViewer = new TreeViewer(composite, SWT.SINGLE
+				| SWT.BORDER);
+		rootstrapTargetViewer.getTree().setLayoutData(
+				new GridData(SWT.FILL, SWT.FILL, true, true));
+
+		showExistingTargets = new Button(composite, SWT.CHECK);
+		showExistingTargets.setText("Show existing targets");
+		showExistingTargets.setSelection(false);
+		showExistingTargets
+				.setToolTipText("If checked, rootstraps with names matching existing targets will be shown.  This is the only way to reinstall a target.");
+
+		useHostTools = new Button(composite, SWT.CHECK);
+		useHostTools.setText("Use host's build tools");
+		useHostTools.setSelection(false);
+		useHostTools
+				.setToolTipText("If checked, configure the rootstrap to use the host versions of autotools, bison, flex, docbook, etc. instead of standard versions (c.f. devkits in scratchbox 1).  We recommend leaving this unchecked and invoking maemo-tools to install official build tools.");
+
+		// / setup rootstrap target tree
+
+		provider = new MaemoRootstrapContentLabelProvider(sdk);
+		rootstrapTargetViewer.setContentProvider(provider);
+		rootstrapTargetViewer.setLabelProvider(provider);
+
+		rootstrapTargetViewer
+				.addSelectionChangedListener(new ISelectionChangedListener() {
+
+					public void selectionChanged(SelectionChangedEvent event) {
+						selection = ((IStructuredSelection) event
+								.getSelection()).getFirstElement();
+						validatePage();
+					}
+
+				});
+
+		provider.addListener(new ILabelProviderListener() {
+
+			public void labelProviderChanged(LabelProviderChangedEvent event) {
+				rootstrapTargetViewer.refresh();
+			}
+
+		});
+
+		rootstrapTargetViewer.getTree().setLinesVisible(true);
+		rootstrapTargetViewer.getTree().setHeaderVisible(true);
+
+		TreeColumn nameColumn = new TreeColumn(rootstrapTargetViewer.getTree(),
+				SWT.LEFT);
+		nameColumn.setText("Target Name");
+		nameColumn.setWidth(200);
+		nameColumn.setResizable(true);
+
+		TreeColumn archColumn = new TreeColumn(rootstrapTargetViewer.getTree(),
+				SWT.LEFT);
+		archColumn.setText("Architecture");
+		archColumn.setWidth(100);
+		archColumn.setResizable(true);
+
+		TreeColumn descColumn = new TreeColumn(rootstrapTargetViewer.getTree(),
+				SWT.LEFT);
+		descColumn.setText("Description");
+		descColumn.setWidth(200);
+		descColumn.setResizable(true);
+
+		rootstrapTargetViewer.setInput(new Object());
+
+		rootstrapTargetViewer.setSelection(StructuredSelection.EMPTY);
+
+		showExistingTargets.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				updateViewerFilters();
+			}
+		});
+
+		updateViewerFilters();
+		setControl(composite);
+	}
+
+	protected void updateViewerFilters() {
+		if (!showExistingTargets.getSelection()) {
+			rootstrapTargetViewer
+					.setFilters(new ViewerFilter[] { new ViewerFilter() {
+
+						@Override
+						public boolean select(Viewer viewer,
+								Object parentElement, Object element) {
+							if (element instanceof MaemoRootstrap) {
+								MaemoRootstrap rootstrap = (MaemoRootstrap) element;
+								if (sdk.findSDKTarget(rootstrap.getName()) != null)
+									return false;
+							}
+							return true;
+						}
+
+					} });
+		} else {
+			rootstrapTargetViewer.setFilters(new ViewerFilter[0]);
+		}
+
+		rootstrapTargetViewer.refresh();
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage
+	 * #perfomeAction()
+	 */
+	public boolean validatePage() {
+		setPageComplete(selection instanceof MaemoRootstrap
+				|| selection == MaemoRootstrapContentLabelProvider.NO_ROOTSTRAP);
+		return true;
+	}
+
+	public boolean canFinish() {
+		return selection instanceof MaemoRootstrap;
+	}
+
+	public MaemoRootstrap getRootstrap() {
+		if (!(selection instanceof MaemoRootstrap))
+			return null;
+		return (MaemoRootstrap) selection;
+	}
+
+	public boolean isShowingExisting() {
+		return showExistingTargets.getSelection();
+	}
+
+	public boolean useHostTools() {
+		return useHostTools.getSelection();
+	}
+
+}
\ No newline at end of file

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/IScratchbox2SDK.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/IScratchbox2SDK.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/IScratchbox2SDK.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.scratchbox.sb2.sdk;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.machine.IMachine;
+
+public interface IScratchbox2SDK extends IScratchboxSDK {
+
+	/**
+	 * Map<String,Map<String, String>> of sb2 target names to a map of the
+	 * target directory to host directory path mappings
+	 */
+	static final String SB2_TARGET_TO_PATH_MAPPINGS_MAP = "sb2_target_to_path_mappings_map";
+	/** Map<String,String> of sb2 target names to rootstrap paths */
+	static final String SB2_TARGET_TO_ROOTSTRAP_MAP = "sb2_target_to_rootstrap_map";
+
+	/**
+	 * @return
+	 */
+	public IPath getScratchbox2ConfigDirectory();
+
+	/**
+	 * Create a new rootstrap target for Scratchbox 2. The target is named after
+	 * a maemo-rootstrap available target.
+	 * 
+	 * @param targetName
+	 *            the name of the new target.
+	 * @param useHostTools
+	 *            if true, use the host toolchain rather than installing devkits
+	 *            in the rootstrap
+	 * @param force
+	 *            if true, then overwrite any existing rootstrap; if false, then
+	 *            let the user choose (in the console :/) whether to overwrite
+	 *            or keep an existing one
+	 * @return true if succeeded, false if failed
+	 * @throws MicaException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean createRootstrapTarget(String targetName,
+			boolean useHostTools, boolean force, IProgressMonitor monitor)
+			throws MicaException;
+
+	/**
+	 * Create a new rootstrap target for Scratchbox 2. The target is named after
+	 * a maemo-rootstrap available target.
+	 * 
+	 * @param targetName
+	 *            the name of the new target.
+	 * @param force
+	 *            if true, then overwrite any existing rootstrap; if false, then
+	 *            let the user choose (in the console :/) whether to overwrite
+	 *            or keep an existing one
+	 * @return true if succeeded, false if failed
+	 * @throws MicaException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean removeRootstrap(String targetName, boolean force,
+			IProgressMonitor monitor) throws MicaException;
+
+	/**
+	 * Get the names of rootstraps already installed. This may inclue those that
+	 * do not have targets associated.
+	 * 
+	 * @param sdk
+	 *            the SDK to check
+	 * @return List, never null
+	 * @throws MicaException
+	 */
+	public List<String> getInstalledMaemoRootstraps() throws MicaException;
+
+	/**
+	 * Get the MaemoRootstrap items available for installation. This includes
+	 * any that might already be defined.
+	 * 
+	 * @return List, never null
+	 * @throws MicaException
+	 */
+	public List<MaemoRootstrap> getAvailableMaemoRootstraps(IMachine machine)
+			throws MicaException;
+
+}

Added: branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/MaemoRootstrap.java
===================================================================
--- branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/MaemoRootstrap.java	                        (rev 0)
+++ branches/sdkPlusSupport/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/scratchbox/sb2/sdk/MaemoRootstrap.java	2008-10-27 07:28:55 UTC (rev 896)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.scratchbox.sb2.sdk;
+
+/**
+ * The data associated with a maemo SDK+ rootstrap
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoRootstrap {
+	private final String name;
+	private final String architecture;
+	private final String description;
+
+	public MaemoRootstrap(String name, String architecture, String description) {
+		this.name = name;
+		this.architecture = architecture;
+		this.description = description;
+
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public String getArchitecture() {
+		return architecture;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result
+				+ ((architecture == null) ? 0 : architecture.hashCode());
+		result = prime * result
+				+ ((description == null) ? 0 : description.hashCode());
+		result = prime * result + ((name == null) ? 0 : name.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		final MaemoRootstrap other = (MaemoRootstrap) obj;
+		if (architecture == null) {
+			if (other.architecture != null)
+				return false;
+		} else if (!architecture.equals(other.architecture))
+			return false;
+		if (description == null) {
+			if (other.description != null)
+				return false;
+		} else if (!description.equals(other.description))
+			return false;
+		if (name == null) {
+			if (other.name != null)
+				return false;
+		} else if (!name.equals(other.name))
+			return false;
+		return true;
+	}
+
+}



More information about the Esbox-commits mailing list