connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java
author Chad Peckham <chad.peckham@nokia.com>
Thu, 11 Feb 2010 16:07:33 -0600
branchRCL_2_4
changeset 941 e90e6ea44529
parent 869 cb5e1f0959c9
child 952 9dba0e2abcff
permissions -rw-r--r--
PnP development for switching USB personalities. Bug 10604.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     1
/*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     3
* All rights reserved.
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     4
* This component and the accompanying materials are made available
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     6
* which accompanies this distribution, and is available
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     8
*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
     9
* Initial Contributors:
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    11
*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    12
* Contributors:
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    13
*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    14
* Description: 
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    15
*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    16
*/
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    17
package com.nokia.carbide.remoteconnections.discovery.pccs.agent;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    18
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    19
import java.net.MalformedURLException;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    20
import java.net.URL;
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
    21
import java.util.Collection;
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    22
import java.util.HashMap;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    23
import java.util.Map;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    24
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    25
import org.eclipse.core.runtime.CoreException;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    26
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    27
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    28
import com.nokia.carbide.remoteconnections.discovery.pccs.Activator;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    29
import com.nokia.carbide.remoteconnections.discovery.pccs.Messages;
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
    30
import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.DeviceConnection;
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    31
import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    32
import com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection.DeviceEventListener;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    33
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    34
import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    35
import com.nokia.carbide.remoteconnections.interfaces.IConnectionType;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    36
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    37
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    38
import com.nokia.carbide.remoteconnections.internal.api.IDeviceDiscoveryAgent;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    39
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    40
/**
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    41
 * Implementation of IDeviceDiscoveryAgent for PCCS USB connection.
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    42
 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    43
public class PCCSDiscoveryAgent implements IDeviceDiscoveryAgent, DeviceEventListener {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    44
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    45
	private static final String USB_CONNECTION_TYPE = 
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    46
		"com.nokia.carbide.trk.support.connection.USBConnectionType"; //$NON-NLS-1$
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    47
	private static final String PORT_SETTING = "port"; //$NON-NLS-1$
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    48
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    49
	public class PCCSPrequisiteStatus implements IPrerequisiteStatus {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    50
		private boolean isOK = true;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    51
		private String errorText;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    52
		private URL errorURL;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    53
		
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    54
		public PCCSPrequisiteStatus() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    55
			isOK = true;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    56
			errorText = null;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    57
			errorURL = null;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    58
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    59
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    60
		public PCCSPrequisiteStatus(boolean ok, String msg, URL url) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    61
			isOK = ok;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    62
			errorText = msg;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    63
			errorURL = url;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    64
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    65
		/* (non-Javadoc)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    66
		 * @see com.nokia.carbide.remoteconnections.internal.api.IDeviceDiscoveryAgent.IPrerequisiteStatus#getErrorText()
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    67
		 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    68
		public String getErrorText() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    69
			return errorText;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    70
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    71
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    72
		/* (non-Javadoc)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    73
		 * @see com.nokia.carbide.remoteconnections.internal.api.IDeviceDiscoveryAgent.IPrerequisiteStatus#getURL()
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    74
		 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    75
		public URL getURL() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    76
			return errorURL;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    77
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    78
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    79
		/* (non-Javadoc)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    80
		 * @see com.nokia.carbide.remoteconnections.internal.api.IDeviceDiscoveryAgent.IPrerequisiteStatus#isOK()
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    81
		 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    82
		public boolean isOK() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    83
			return isOK;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    84
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    85
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    86
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    87
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    88
	protected Map<String, IConnection2> connections;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    89
	protected IConnectionsManager manager;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    90
	protected PCCSConnection pccsConnection;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    91
	private IPrerequisiteStatus loadStatus = new PCCSPrequisiteStatus();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    92
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    93
	/**
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    94
	 * Constructs a PCCSDiscoveryAgent object
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    95
	 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    96
	public PCCSDiscoveryAgent() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    97
		connections = new HashMap<String, IConnection2>();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    98
		manager = RemoteConnectionsActivator.getConnectionsManager();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
    99
		pccsConnection = new PCCSConnection();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   100
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   101
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   102
	private boolean isSymSEELayout() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   103
		return Activator.isSymSEELayout();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   104
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   105
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   106
	/*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   107
	 * (non-Javadoc)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   108
	 * @see com.nokia.carbide.remoteconnections.internal.IDeviceDiscoveryAgent#getInformation()
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   109
	 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   110
	public URL getInformation() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   111
		return null;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   112
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   113
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   114
	/*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   115
	 * (non-Javadoc)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   116
	 * @see com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection.DeviceEventListener#onDeviceEvent(com.nokia.carbide.remoteconnections.discovery.pccs.pccsnative.PCCSConnection.DeviceEventListener.DeviceEvent, java.lang.String)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   117
	 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   118
	public void onDeviceEvent(DeviceEvent eventType, String serialNumber) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   119
		try {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   120
			switch (eventType) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   121
			case DEVICE_LIST_UPDATED:
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   122
			case DEVICE_ADDED:
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   123
			case DEVICE_REMOVED:
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   124
			case DEVICE_UPDATED_ADDEDCONNECTION:
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   125
			case DEVICE_UPDATED_REMOVEDCONNECTION:
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   126
				updateConnections(pccsConnection.getGoodConnectionList());
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   127
				break;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   128
			case DEVICE_UPDATED_RENAMED:
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   129
				// TODO what to do when device is renamed?
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   130
				break;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   131
			}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   132
		} catch (CoreException e) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   133
			RemoteConnectionsActivator.logError(e);
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   134
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   135
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   136
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   137
	/*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   138
	 * (non-Javadoc)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   139
	 * @see com.nokia.carbide.remoteconnections.internal.IDeviceDiscoveryAgent#start()
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   140
	 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   141
	public void start() throws CoreException {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   142
		try {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   143
			pccsConnection.open();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   144
		} catch (CoreException ce) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   145
			saveLoadStatus(ce);
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   146
			throw ce;		// rethrow
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   147
		}
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   148
		updateConnections(pccsConnection.getGoodConnectionList());
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   149
		pccsConnection.addEventListenter(this);
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   150
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   151
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   152
	private void saveLoadStatus(CoreException ce) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   153
		String msg = null;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   154
		URL location = null;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   155
		if (isSymSEELayout()) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   156
			if (ce.getStatus().getCode() == PCCSConnection.PCCS_NOT_FOUND)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   157
				msg = Messages.PCCSDiscoveryAgent_PCCS_Not_Found_Error;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   158
			else
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   159
				msg = Messages.PCCSDiscoveryAgent_PCCS_Version_Error;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   160
			
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   161
			try {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   162
				location = new URL(Activator.getLoadErrorURL());
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   163
			} catch (MalformedURLException e) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   164
			}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   165
		} else {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   166
			if (ce.getStatus().getCode() == PCCSConnection.PCCS_NOT_FOUND)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   167
				msg = Messages.PCCSDiscoveryAgent_PCSuite_Not_Found_Error;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   168
			else
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   169
				msg = Messages.PCCSDiscoveryAgent_PCSuite_Version_Error;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   170
			
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   171
			try {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   172
				location = new URL(Activator.getLoadErrorURL());
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   173
			} catch (MalformedURLException e) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   174
			}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   175
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   176
		loadStatus = new PCCSPrequisiteStatus(false, msg, location);
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   177
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   178
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   179
	/*
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   180
	 * (non-Javadoc)
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   181
	 * @see com.nokia.carbide.remoteconnections.internal.IDeviceDiscoveryAgent#stop()
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   182
	 */
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   183
	public void stop() throws CoreException {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   184
		pccsConnection.removeEventListener(this);
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   185
		pccsConnection.close();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   186
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   187
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   188
	/**
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   189
	 * Creates a new PCCS connection
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   190
	 * @param deviceConn - device/connection information from PCCS
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   191
	 */
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   192
	protected void createConnection(DeviceConnection deviceConn) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   193
		if (connections.get(getKey(deviceConn)) == null) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   194
			// TODO: currently only handles USB & Serial
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   195
			if (deviceConn.media.equals("usb")) { //$NON-NLS-1$
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   196
				if (deviceConn.mode.equals("serial")) { //$NON-NLS-1$
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   197
					IConnectionType connectionType = 
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   198
						RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionType(USB_CONNECTION_TYPE);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   199
					if (connectionType != null) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   200
						IConnectionFactory factory = connectionType.getConnectionFactory();
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   201
						Map<String, String> settings = factory.getSettingsFromUI();
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   202
						settings.put(PORT_SETTING, deviceConn.port);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   203
						IConnection connection = factory.createConnection(settings);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   204
						if (connection instanceof IConnection2) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   205
							IConnection2 connection2 = (IConnection2) connection;
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   206
							connection2.setIdentifier(createUniqueId(deviceConn));
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   207
							connection2.setDisplayName(deviceConn.friendlyName);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   208
							connection2.setDynamic(true);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   209
							String key = getKey(deviceConn);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   210
							connections.put(key, connection2);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   211
							manager.addConnection(connection2);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   212
						}
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   213
						else {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   214
							RemoteConnectionsActivator.log("Could not create dynamic serial connection", null);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   215
						}
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   216
					}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   217
					else {
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   218
						RemoteConnectionsActivator.log("USB connection type extension not found", null);
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   219
					}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   220
				}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   221
			}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   222
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   223
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   224
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   225
	/**
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   226
	 * Create a unique ID based on this device/connection
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   227
	 * @param conn - device/connection information from PCCS
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   228
	 * @return
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   229
	 */
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   230
	private String createUniqueId(DeviceConnection conn) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   231
		return getClass().getSimpleName() + ": " + conn.friendlyName; //$NON-NLS-1$
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   232
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   233
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   234
	/**
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   235
	 * Return a string key based on the device and connection information
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   236
	 * @param conn - device/connection information
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   237
	 * @return
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   238
	 */
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   239
	protected String getKey(DeviceConnection conn) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   240
		String key = conn.friendlyName + conn.serialNumber + conn.address;
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   241
		return key;
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   242
	}
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   243
	/**
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   244
	 * Update existing PCCS connections
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   245
	 * @param connList - the Device/Connection list from PCCS
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   246
	 */
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   247
	protected void updateConnections(Collection<DeviceConnection> connList) {
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   248
		disconnectAll();
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   249
 		if (connList != null && !connList.isEmpty()) {
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   250
			if (connections.isEmpty()) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   251
				// no existing connections, so create new ones
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   252
				for (DeviceConnection deviceConn : connList) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   253
					createConnection(deviceConn);
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   254
				}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   255
			}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   256
			else {
941
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   257
				for (DeviceConnection deviceConn : connList) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   258
					String key = getKey(deviceConn);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   259
					IConnection2 connection = connections.get(key);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   260
					if (connection == null) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   261
						// no existing connection for the device found, must be new connection
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   262
						createConnection(deviceConn);
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   263
					} else {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   264
						if (!manager.reconnect(connection)) {
e90e6ea44529 PnP development for switching USB personalities. Bug 10604.
Chad Peckham <chad.peckham@nokia.com>
parents: 869
diff changeset
   265
							manager.addConnection(connection);
869
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   266
						}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   267
					}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   268
				}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   269
			}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   270
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   271
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   272
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   273
	private void disconnectAll() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   274
		for (IConnection2 connection : connections.values()) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   275
			manager.disconnect(connection);
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   276
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   277
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   278
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   279
	public String getDisplayName() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   280
		return Activator.getDisplayName();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   281
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   282
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   283
	public IPrerequisiteStatus getPrerequisiteStatus() {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   284
		// Manager calls this first so we can check if we can load.
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   285
		// so let's open the discovery and close it catching any exceptions.
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   286
		try {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   287
			pccsConnection.open();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   288
			// successful load - close it as start() will open again
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   289
			pccsConnection.close();
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   290
		} catch (CoreException ce) {
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   291
			saveLoadStatus(ce);
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   292
		}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   293
		
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   294
		return loadStatus;
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   295
	}
cb5e1f0959c9 move com.nokia.carbide.remoteConnections.discovery.pccs to carbidecpp repository
cawthron
parents:
diff changeset
   296
}