# HG changeset patch # User dan.podwall@nokia.com # Date 1239044450 18000 # Node ID 9107fae37cee04fb02c2fa17e189aa371e50d3b6 # Parent a34cdcced64eee5ff0f5ba6d9479be47ad9d537f# Parent e4eb00aa1a3fbff1674ca33a4a8894cc14e2770f merge on RCL_2_0 diff -r a34cdcced64e -r 9107fae37cee .hgignore --- a/.hgignore Mon Apr 06 11:48:01 2009 -0500 +++ b/.hgignore Mon Apr 06 14:00:50 2009 -0500 @@ -1,6 +1,5 @@ # use glob syntax. syntax: glob -*.class bin runtime .DS_Store diff -r a34cdcced64e -r 9107fae37cee connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService.java --- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService.java Mon Apr 06 11:48:01 2009 -0500 +++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService.java Mon Apr 06 14:00:50 2009 -0500 @@ -32,7 +32,7 @@ public abstract class AbstractConnectedService implements IConnectedService { - protected final static int TIMEOUT = 2000; + public final static int TIMEOUT = 2000; public static class ConnectionFailException extends Exception { public ConnectionFailException(String string) { @@ -122,6 +122,7 @@ protected IRunnableContext runnableContext; protected Status currentStatus; protected Tester tester; + protected boolean manualTesting; public AbstractConnectedService(IService service, AbstractSynchronizedConnection connection) { this.service = service; @@ -173,7 +174,7 @@ } public void testStatus() { - if (!isEnabled()) + if (!(isEnabled() || manualTesting)) return; final TestResult result[] = { null }; @@ -196,12 +197,16 @@ result[0] = runTestStatus(new NullProgressMonitor()); } - if (!isEnabled()) // could be waiting for response past when service testing was disabled + if (!(isEnabled() || manualTesting)) // could be waiting for response past when service testing was disabled return; if (result[0].shortDescription != null && result[0].longDescription != null) { currentStatus.setEStatus(result[0].estatus, result[0].shortDescription, result[0].longDescription); } } + + public void setManualTesting() { + manualTesting = true; + } public boolean isEnabled() { return tester != null; diff -r a34cdcced64e -r 9107fae37cee connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java --- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Mon Apr 06 11:48:01 2009 -0500 +++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Mon Apr 06 14:00:50 2009 -0500 @@ -23,6 +23,7 @@ import com.nokia.carbide.remoteconnections.interfaces.*; import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus; import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener; +import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus; import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory.IValidationErrorReporter; import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller; import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller.IPackageContents; @@ -55,6 +56,23 @@ import java.util.List; public class ConnectionSettingsPage extends WizardPage { + + public final class Tester extends Thread { + @Override + public void run() { + ((AbstractConnectedService) connectedService).setManualTesting(); + for (int i = 0; i < 3 && connectedService != null; i++) { + connectedService.testStatus(); + try { + if (i < 2) + sleep(AbstractConnectedService.TIMEOUT); + } catch (InterruptedException e) { + break; + } + } + resetServiceTesting(false); + } + } private final static TreeNode LOADING_CONTENT_TREENODE = new TreeNode(Messages.getString("ConnectionSettingsPage.GettingDataMessage")); //$NON-NLS-1$ @@ -78,8 +96,9 @@ private IConnectionFactory connectionFactory; private IConnection connection; private IService service; - private IConnectedService connectedService; + private volatile IConnectedService connectedService; private IStatusChangedListener statusListener; + private Tester tester; private SashForm installerSashForm; private TreeViewer installerTreeViewer; private Text installerInfoText; @@ -201,7 +220,7 @@ IService curService = (IService) selection.getFirstElement(); if (!curService.equals(service)) { service = curService; - resetServiceTesting(); + resetServiceTesting(true); } } }); @@ -230,7 +249,7 @@ public void widgetSelected(SelectionEvent e) { if (isTesting) { serviceTestButton.setText(Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel")); //$NON-NLS-1$ - resetServiceTesting(); + resetServiceTesting(true); } else { serviceTestButton.setText(Messages.getString("ConnectionSettingsPage.StopServiceTestButtonLabel")); //$NON-NLS-1$ @@ -443,7 +462,7 @@ } servicesListViewer.getList().addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { - resetServiceTesting(); + resetServiceTesting(true); } }); @@ -505,7 +524,7 @@ } deviceOSComboViewer.getCombo().addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { - resetServiceTesting(); + resetServiceTesting(true); } }); } @@ -568,13 +587,16 @@ public void run() { if (!statusText.isDisposed()) statusText.setText(status.getLongDescription()); + if (status.getEStatus().equals(EStatus.UP)) + resetServiceTesting(false); } }); } }); if (connectedService instanceof AbstractConnectedService) ((AbstractConnectedService) connectedService).setRunnableContext(getContainer()); - connectedService.setEnabled(true); + tester = new Tester(); + tester.start(); isTesting = true; } } @@ -764,16 +786,23 @@ } } - private void resetServiceTesting() { + private void resetServiceTesting(final boolean resetAll) { isTesting = false; if (service == null) return; - serviceTestInfo.setText(service.getAdditionalServiceInfo()); - agentTestTabComposite.layout(true, true); - statusText.setText(STATUS_NOT_TESTED); - disposeConnectedService(); - String buttonLabel = Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel"); //$NON-NLS-1$ - serviceTestButton.setText(buttonLabel); + // may be called from a test thread + Display.getDefault().syncExec(new Runnable() { + public void run() { + if (resetAll) { + statusText.setText(STATUS_NOT_TESTED); + serviceTestInfo.setText(service.getAdditionalServiceInfo()); + agentTestTabComposite.layout(true, true); + } + disposeConnectedService(); + String buttonLabel = Messages.getString("ConnectionSettingsPage.StartServiceTestButtonLabel"); //$NON-NLS-1$ + serviceTestButton.setText(buttonLabel); + } + }); } }