[Bug 9085] Add new TCP/IP connection type with port mappings and new service interface to optionally provide defaults.
authordadubrow
Tue, 19 May 2009 15:27:20 -0500
changeset 163 b25acbfc406a
parent 162 9cf153286621
child 164 88b7eb94b003
[Bug 9085] Add new TCP/IP connection type with port mappings and new service interface to optionally provide defaults.
connectivity/com.nokia.carbide.remoteConnections.tests/plugin.xml
connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/AllTests.java
connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/ConnectedServiceFactory.java
connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/RandomCycleConnectedService.java
connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/TestFilter.java
connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/TestInstallerProvider.java
connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/UnknownStatusService.java
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IService.java
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/SettingsWizard.java
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java
debuggercdi/com.nokia.carbide.trk.support/plugin.xml
debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/connection/TCPIPConnectionType.java
--- a/connectivity/com.nokia.carbide.remoteConnections.tests/plugin.xml	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections.tests/plugin.xml	Tue May 19 15:27:20 2009 -0500
@@ -57,5 +57,11 @@
             class="com.nokia.carbide.remoteconnections.tests.extensions.ConnectedServiceFactory">
       </connectedServiceFactory>
    </extension>
+   <extension
+         point="com.nokia.carbide.remoteConnections.service">
+      <service
+            class="com.nokia.carbide.remoteconnections.tests.extensions.DefaultProvidingTCPIPService">
+      </service>
+   </extension>
 
 </plugin>
--- a/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/AllTests.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/AllTests.java	Tue May 19 15:27:20 2009 -0500
@@ -29,6 +29,7 @@
 		suite.addTestSuite(SerializationTest.class);
 		suite.addTestSuite(ServiceTest.class);
 		suite.addTestSuite(FilterTest.class);
+		suite.addTestSuite(TCPIPConnectionTypeTests.class);
 		//$JUnit-END$
 		return suite;
 	}
--- a/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/ConnectedServiceFactory.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/ConnectedServiceFactory.java	Tue May 19 15:27:20 2009 -0500
@@ -18,10 +18,12 @@
 package com.nokia.carbide.remoteconnections.tests.extensions;
 
 import com.nokia.carbide.remoteconnections.interfaces.*;
+import com.nokia.carbide.trk.support.connection.TCPIPConnectionType;
 
 import java.util.*;
 
 
+@SuppressWarnings("restriction")
 public class ConnectedServiceFactory implements IConnectedServiceFactory {
 
 	public IConnectedService createConnectedService(IService service, IConnection connection) {
@@ -30,16 +32,28 @@
 		else if (service instanceof UnknownStatusService) {
 			return ((UnknownStatusService) service).createInstance(connection);
 		}
+		else if (service instanceof DefaultProvidingTCPIPService) {
+			return ((DefaultProvidingTCPIPService) service).createInstance(connection);
+		}
 		return null;
 	}
 
 	public Collection<String> getCompatibleConnectionTypeIds(IService service) {
-		if (service instanceof RandomCycleService)
-			return Collections.singleton(IntervalConnectionType.class.getName());
+		if (service instanceof RandomCycleService) {
+			return Arrays.asList(
+					new String[] 
+			        {IntervalConnectionType.class.getName(),
+					TCPIPConnectionType.ID});
+		}
 		else if (service instanceof UnknownStatusService) {
-			String[] ids = {IntervalConnectionType.class.getName(),
-					NoSettingsConnectionType.class.getName()};
-			return Arrays.asList(ids);
+			return Arrays.asList(
+					new String[] 
+					{IntervalConnectionType.class.getName(),
+					NoSettingsConnectionType.class.getName(), 
+					TCPIPConnectionType.ID});
+		}
+		else if (service instanceof DefaultProvidingTCPIPService) {
+			return Collections.singleton(TCPIPConnectionType.ID);
 		}
 		return Collections.EMPTY_LIST;
 	}
--- a/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/RandomCycleConnectedService.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/RandomCycleConnectedService.java	Tue May 19 15:27:20 2009 -0500
@@ -87,8 +87,8 @@
 		}
 
 		public void run() {
-			IntervalConnection testConnection = service.getConnection();
-			int msInterval = testConnection.getInterval();
+			IConnection testConnection = service.getConnection();
+			int msInterval = testConnection instanceof IntervalConnection ? ((IntervalConnection) testConnection).getInterval() : 1000;
 			try {
 				Thread.sleep(msInterval);
 			} catch (InterruptedException e) {
@@ -177,7 +177,7 @@
 	}
 
 	private ListenerList<IStatusChangedListener> listeners;
-	private IntervalConnection connection;
+	private IConnection connection;
 	private EStatus status;
 	private RandomCycleScheduler downageScheduler;
 	private final IService service;
@@ -185,8 +185,7 @@
 	private static Random rand;
 
 	public RandomCycleConnectedService(IService service, IConnection connection) {
-		Check.checkContract(connection instanceof IntervalConnection);
-		this.connection = (IntervalConnection) connection;
+		this.connection = connection;
 		this.service = service;
 		status = EStatus.DOWN;
 		if (downageScheduler == null) {
@@ -240,7 +239,7 @@
 		t.start();
 	}
 
-	public IntervalConnection getConnection() {
+	public IConnection getConnection() {
 		return connection;
 	}
 
--- a/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/TestFilter.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/TestFilter.java	Tue May 19 15:27:20 2009 -0500
@@ -33,7 +33,7 @@
 	private static List<String> serviceIds = new ArrayList<String>();
 	private static List<Pair<String, String>> connectedServiceIdPairs = new ArrayList<Pair<String,String>>();
 	
-	public static boolean isTest;
+	public static boolean isTest = true;
 
 	public static void reset() {
 		connectionTypeIds.clear();
--- a/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/TestInstallerProvider.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/TestInstallerProvider.java	Tue May 19 15:27:20 2009 -0500
@@ -128,11 +128,12 @@
 	public List<String> getSDKFamilyNames(IRunnableContext runnableContext) {
 		if (!initialized) {
 			try {
-				runnableContext.run(false, false, new IRunnableWithProgress() {
-					public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-						getMockData(monitor);
-					}
-				});
+				if (runnableContext != null)
+					runnableContext.run(false, false, new IRunnableWithProgress() {
+						public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+							getMockData(monitor);
+						}
+					});
 			} catch (Exception e) {
 				e.printStackTrace();
 			}
--- a/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/UnknownStatusService.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections.tests/src/com/nokia/carbide/remoteconnections/tests/extensions/UnknownStatusService.java	Tue May 19 15:27:20 2009 -0500
@@ -19,6 +19,7 @@
 package com.nokia.carbide.remoteconnections.tests.extensions;
 
 import com.nokia.carbide.remoteconnections.interfaces.*;
+import com.nokia.carbide.trk.support.connection.TCPIPConnectionFactory;
 
 import org.eclipse.jface.operation.IRunnableContext;
 import org.eclipse.swt.graphics.Image;
@@ -28,7 +29,8 @@
 import java.io.InputStream;
 import java.util.*;
 
-public class UnknownStatusService implements IService {
+@SuppressWarnings("restriction")
+public class UnknownStatusService implements IService2 {
 
 	private static final String _5_0 = "5.0";
 	private static final String S60 = "S60";
@@ -173,4 +175,16 @@
 		return false;
 	}
 
+	public Map<String, String> getDefaults() {
+		return Collections.singletonMap(TCPIPConnectionFactory.IP_PORT, "10000");
+	}
+
+	public boolean wantsDeviceOS() {
+		return false;
+	}
+
+	public Object getAdapter(Class adapter) {
+		return null;
+	}
+
 }
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IService.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IService.java	Tue May 19 15:27:20 2009 -0500
@@ -18,7 +18,6 @@
 
 package com.nokia.carbide.remoteconnections.interfaces;
 
-import java.util.Collection;
 
 /**
  * The interface for remote service extension
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties	Tue May 19 15:27:20 2009 -0500
@@ -10,7 +10,7 @@
 ConnectionSettingsPage.AgentTestTabLabel=Set Connection Settings
 ConnectionSettingsPage.ConnectionSettingsGroupLabel=Connection Settings
 ConnectionSettingsPage.DeviceOSComboToolTip=Used to determine which installer version to compare against the version reported by the remote agent
-ConnectionSettingsPage.DeviceOSLabel=Device OS:
+ConnectionSettingsPage.DeviceOSLabel=Device OS (used for service test results):
 ConnectionSettingsPage.GettingDataMessage=Getting data from server...
 ConnectionSettingsPage.InstallButtonLabel=Install
 ConnectionSettingsPage.InstallButtonToolTip=Run installer file
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java	Tue May 19 15:27:20 2009 -0500
@@ -220,6 +220,7 @@
 				IService curService = (IService) selection.getFirstElement();
 				if (!curService.equals(service)) {
 					service = curService;
+					serviceTestButton.setEnabled(service.isTestable()); 
 					resetServiceTesting(true);
 				}
 			}
@@ -593,10 +594,11 @@
 					});
 				}
 			});
-			if (connectedService instanceof AbstractConnectedService)
+			if (connectedService instanceof AbstractConnectedService) {
 				((AbstractConnectedService) connectedService).setRunnableContext(getContainer());
-			tester = new Tester();
-			tester.start();
+				tester = new Tester();
+				tester.start();
+			}
 			isTesting = true;
 		}
 	}
@@ -797,6 +799,10 @@
 					statusText.setText(STATUS_NOT_TESTED);
 					serviceTestInfo.setText(service.getAdditionalServiceInfo());
 					agentTestTabComposite.layout(true, true);
+					boolean wantsDeviceOS = service.getInstallerProvider() != null;
+					if (service instanceof IService2)
+						wantsDeviceOS &= ((IService2) service).wantsDeviceOS();
+					deviceOSComboViewer.getCombo().setEnabled(wantsDeviceOS);
 				}
 				disposeConnectedService();
 				if (!serviceTestButton.isDisposed()) {
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/SettingsWizard.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/SettingsWizard.java	Tue May 19 15:27:20 2009 -0500
@@ -112,6 +112,7 @@
 		}
 		
 		enableConnectedServices(true);
+		RemoteConnectionsActivator.getConnectionsManager().storeConnections();
 		return true;
 	}
 	
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java	Tue May 19 10:08:04 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java	Tue May 19 15:27:20 2009 -0500
@@ -169,6 +169,7 @@
 			connection.setDisplayName(value.toString());
 			viewer.refresh(true);
 			packColumns();
+			RemoteConnectionsActivator.getConnectionsManager().storeConnections();
 		}
 	}
 
--- a/debuggercdi/com.nokia.carbide.trk.support/plugin.xml	Tue May 19 10:08:04 2009 -0500
+++ b/debuggercdi/com.nokia.carbide.trk.support/plugin.xml	Tue May 19 15:27:20 2009 -0500
@@ -38,5 +38,11 @@
             class="com.nokia.carbide.trk.support.service.ConnectedServiceFactory">
       </connectedServiceFactory>
    </extension>
+   <extension
+         point="com.nokia.carbide.remoteConnections.connectionType">
+      <connectionType
+            class="com.nokia.carbide.trk.support.connection.TCPIPConnectionType">
+      </connectionType>
+   </extension>
  	
 </plugin>
--- a/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/connection/TCPIPConnectionType.java	Tue May 19 10:08:04 2009 -0500
+++ b/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/connection/TCPIPConnectionType.java	Tue May 19 15:27:20 2009 -0500
@@ -27,10 +27,10 @@
  */
 public class TCPIPConnectionType implements IConnectionType {
 
-	public static final String ID = TCPIPConnectionType.class.getName();
+	public static final String ID = "com.nokia.carbide.connection.TCPIPConnectionType"; //$NON-NLS-1$
 
 	public IConnectionFactory getConnectionFactory() {
-		return new TCPIPConnectionFactory(this);
+		return new TCPIPPortMappingConnectionFactory(this);
 	}
 
 	public String getDescription() {