Fix bug 10618
authorChad Peckham <chad.peckham@nokia.com>
Mon, 15 Feb 2010 13:26:34 -0600
changeset 955 d96d53142a85
parent 948 ee68c935ffb7
child 957 945f32ff50e5
Fix bug 10618
connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java
--- a/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java	Fri Feb 12 14:41:28 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections.discovery.pccs/src/com/nokia/carbide/remoteconnections/discovery/pccs/agent/PCCSDiscoveryAgent.java	Mon Feb 15 13:26:34 2010 -0600
@@ -21,6 +21,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.eclipse.core.runtime.CoreException;
 
@@ -228,7 +229,7 @@
 	 * @return
 	 */
 	private String createUniqueId(DeviceConnection conn) {
-		return getClass().getSimpleName() + ": " + conn.friendlyName; //$NON-NLS-1$
+		return getClass().getSimpleName() + ": " + conn.friendlyName + ": " + conn.address; //$NON-NLS-1$
 	}
 
 	/**
@@ -271,8 +272,22 @@
 	}
 
 	private void disconnectAll() {
-		for (IConnection2 connection : connections.values()) {
-			manager.disconnect(connection);
+		if (connections.isEmpty())
+			return;
+		Set<String> keySet = connections.keySet();
+		for (String key : keySet) {
+			IConnection2 connection = connections.get(key);
+			// if manager knows about this connection, disconnect
+			// otherwise it has already been removed from our system
+			if (manager.findConnection(connection.getIdentifier()) != null) {
+				// not removed yet, disconnect only
+				manager.disconnect(connection);
+			} else {
+				// it's been removed from system
+				// remove it from our list also
+				connections.remove(key);
+			}
+			
 		}
 	}