[Esbox-commits] r840 - in trunk/device/org.maemo.esbox.device.launch.rse: . META-INF src/org/maemo/esbox/device/launch/rse

lwang at garage.maemo.org lwang at garage.maemo.org
Wed Oct 8 02:27:04 EEST 2008


Author: lwang
Date: 2008-10-08 02:27:03 +0300 (Wed, 08 Oct 2008)
New Revision: 840

Added:
   trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/MaemoDefaultRSEConnection.java
Modified:
   trunk/device/org.maemo.esbox.device.launch.rse/META-INF/MANIFEST.MF
   trunk/device/org.maemo.esbox.device.launch.rse/plugin.xml
Log:
Default RSE connection provider for Nokia tablet.

Modified: trunk/device/org.maemo.esbox.device.launch.rse/META-INF/MANIFEST.MF
===================================================================
--- trunk/device/org.maemo.esbox.device.launch.rse/META-INF/MANIFEST.MF	2008-10-07 19:51:33 UTC (rev 839)
+++ trunk/device/org.maemo.esbox.device.launch.rse/META-INF/MANIFEST.MF	2008-10-07 23:27:03 UTC (rev 840)
@@ -12,7 +12,6 @@
  org.eclipse.rse.services;bundle-version="3.0.1",
  org.maemo.esbox.launch;bundle-version="1.5.0",
  org.maemo.esbox.core;bundle-version="1.5.0",
- org.maemo.esbox.ui;bundle-version="1.5.0",
  org.maemo.esbox.ssh;bundle-version="1.5.0",
  org.maemo.esbox.device.core;bundle-version="1.5.0",
  org.maemo.esbox.device.launch;bundle-version="1.5.0"

Modified: trunk/device/org.maemo.esbox.device.launch.rse/plugin.xml
===================================================================
--- trunk/device/org.maemo.esbox.device.launch.rse/plugin.xml	2008-10-07 19:51:33 UTC (rev 839)
+++ trunk/device/org.maemo.esbox.device.launch.rse/plugin.xml	2008-10-07 23:27:03 UTC (rev 840)
@@ -17,5 +17,12 @@
             launch_protocol_id="org.maemo.esbox.device.launch.rse.RSELaunchProtocol">
       </launch_protocol_page>
    </extension>
+   <extension
+         point="org.eclipse.rse.core.modelInitializers">
+      <modelInitializer
+            class="org.maemo.esbox.device.launch.rse.MaemoDefaultRSEConnection"
+            type="session">
+      </modelInitializer>
+   </extension>
 
 </plugin>

Added: trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/MaemoDefaultRSEConnection.java
===================================================================
--- trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/MaemoDefaultRSEConnection.java	                        (rev 0)
+++ trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/MaemoDefaultRSEConnection.java	2008-10-07 23:27:03 UTC (rev 840)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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:
+ *    Ling Wang (Nokia) - initial version. Oct 7, 2008
+ *******************************************************************************/
+
+package org.maemo.esbox.device.launch.rse;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.rse.core.IRSEModelInitializer;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.IRSEUserIdConstants;
+import org.eclipse.rse.core.RSECorePlugin;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemProfile;
+import org.eclipse.rse.core.model.ISystemProfileManager;
+import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
+import org.maemo.esbox.internal.device.launch.rse.Activator;
+
+/**
+ * RSEModelInitializer that creates the default connection for Maemo device.
+ * 
+ * @author LWang
+ *
+ */
+public class MaemoDefaultRSEConnection implements IRSEModelInitializer {
+
+	// This is the extension ID from 
+	//  org.eclipse.rse.subsystems.processes.shell.linux/plugin.xml
+	private static String SSHProcessSubsystemConfigurationExtensionID = "processes.shell.linux";
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.rse.core.IRSEModelInitializer#run(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public IStatus run(IProgressMonitor monitor) {
+		IStatus status = Status.OK_STATUS;
+
+		ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
+		ISystemProfileManager profileManager = RSECorePlugin.getTheSystemProfileManager();
+		ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile();
+		String connectionName = "Nokia Internet Tablet";
+		
+		IHost host = registry.getHost(profile, connectionName);
+		if (host == null) {
+			// create an SSH-ONLY host first, which will by default contain file, shell and
+			// terminal subsystems based on SSH connector. Then we just need to add process
+			// subsystem.
+			// Another approach is creating a LINUX type host, but its default subsystems are
+			// based on DStore connector that we don't want.
+			//
+			IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID);
+			if (systemType != null && systemType.isEnabled()) {
+				try {
+					// Create SSH-only host first.
+					host = registry.createHost(profile.getName(), systemType, connectionName, "192.168.2.15", "Default connection for Nokia Internet tablet", true);
+					
+					// Find the Linux Shell Process subsystem configuration.
+					// This may not be a safe way, but I cannot find a better one.
+					//
+					ISubSystemConfiguration linuxShellProcessSSC = registry.getSubSystemConfiguration(SSHProcessSubsystemConfigurationExtensionID);
+					
+					if (linuxShellProcessSSC == null) {
+						// Should not happen.
+						throw new Exception("Linux Shell Process subsystem configuration (the extension) is not installed.");
+					}
+					
+					// Now add the Shell process subsystem to the host.
+					registry.createSubSystems(host, new ISubSystemConfiguration[] {linuxShellProcessSSC});
+					
+					String userName = System.getProperty("user.name"); //$NON-NLS-1$
+
+					IRSESystemType linuxSystemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LINUX_ID);
+
+					// I have to call this to make sure the new Process subsystem appear under the host in UI.
+					//
+					registry.updateHost(host, linuxSystemType, connectionName, host.getHostName(), 
+								host.getDescription(), userName, IRSEUserIdConstants.USERID_LOCATION_HOST);
+					
+				} catch (Exception e) {
+					if (host != null)
+						registry.deleteHost(host);	// unfortunately this does not work.
+					
+					return new Status(IStatus.ERROR, 
+							Activator.getUniqueIdentifier(), 
+							"Fail to create default connection for " + connectionName, 
+							e);
+				}
+			}
+		}
+		
+		monitor.done();
+		
+		return status;
+	}
+
+}


Property changes on: trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/MaemoDefaultRSEConnection.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the Esbox-commits mailing list