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