Lines 18-23
Link Here
|
18 |
package org.eclipse.rse.internal.connectorservice.telnet; |
18 |
package org.eclipse.rse.internal.connectorservice.telnet; |
19 |
|
19 |
|
20 |
import java.io.InputStream; |
20 |
import java.io.InputStream; |
|
|
21 |
import java.io.OutputStream; |
21 |
import java.io.PrintStream; |
22 |
import java.io.PrintStream; |
22 |
import java.lang.reflect.InvocationTargetException; |
23 |
import java.lang.reflect.InvocationTargetException; |
23 |
|
24 |
|
Lines 60-66
Link Here
|
60 |
|
61 |
|
61 |
private static final int TELNET_DEFAULT_PORT = 23; // TODO Make configurable |
62 |
private static final int TELNET_DEFAULT_PORT = 23; // TODO Make configurable |
62 |
private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable |
63 |
private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable |
63 |
private TelnetClient fTelnetClient = new TelnetClient(); |
64 |
private TelnetClient fTelnetClient ; |
64 |
private SessionLostHandler fSessionLostHandler; |
65 |
private SessionLostHandler fSessionLostHandler; |
65 |
private InputStream in; |
66 |
private InputStream in; |
66 |
private PrintStream out; |
67 |
private PrintStream out; |
Lines 69-75
Link Here
|
69 |
private static final int SUCCESS_CODE = 150; // login pass code |
70 |
private static final int SUCCESS_CODE = 150; // login pass code |
70 |
private static final int CONNECT_CLOSED = 200; // code for end of login attempts |
71 |
private static final int CONNECT_CLOSED = 200; // code for end of login attempts |
71 |
private static final int CONNECT_CANCELED = 250; // code for cancel progress |
72 |
private static final int CONNECT_CANCELED = 250; // code for cancel progress |
72 |
|
73 |
private int numberOfConnections = 0; |
|
|
74 |
private String sessionPassword = ""; |
75 |
|
73 |
public TelnetConnectorService(IHost host) { |
76 |
public TelnetConnectorService(IHost host) { |
74 |
super(TelnetConnectorResources.TelnetConnectorService_Name, |
77 |
super(TelnetConnectorResources.TelnetConnectorService_Name, |
75 |
TelnetConnectorResources.TelnetConnectorService_Description, |
78 |
TelnetConnectorResources.TelnetConnectorService_Description, |
Lines 116-125
Link Here
|
116 |
Exception nestedException = null; |
119 |
Exception nestedException = null; |
117 |
try { |
120 |
try { |
118 |
Activator.trace("Telnet Service: Connecting....."); //$NON-NLS-1$ |
121 |
Activator.trace("Telnet Service: Connecting....."); //$NON-NLS-1$ |
|
|
122 |
fTelnetClient = new TelnetClient(); |
119 |
fTelnetClient.connect(host, TELNET_DEFAULT_PORT); |
123 |
fTelnetClient.connect(host, TELNET_DEFAULT_PORT); |
120 |
SystemSignonInformation ssi = getSignonInformation(); |
124 |
if( numberOfConnections == 0) { |
121 |
if (ssi != null) { |
125 |
SystemSignonInformation ssi = getSignonInformation(); |
122 |
password = ssi.getPassword(); |
126 |
if (ssi != null) { |
|
|
127 |
password = ssi.getPassword(); |
128 |
setSessionPassword( password ); |
129 |
} |
130 |
}else { |
131 |
password = getSessionPassword(); |
123 |
} |
132 |
} |
124 |
|
133 |
|
125 |
in = fTelnetClient.getInputStream(); |
134 |
in = fTelnetClient.getInputStream(); |
Lines 158-166
Link Here
|
158 |
Activator.trace("Telnet Service: Canceled"); //$NON-NLS-1$ |
167 |
Activator.trace("Telnet Service: Canceled"); //$NON-NLS-1$ |
159 |
sessionDisconnect(); //will eventually destroy the LoginThread |
168 |
sessionDisconnect(); //will eventually destroy the LoginThread |
160 |
} else if (status == SUCCESS_CODE) { |
169 |
} else if (status == SUCCESS_CODE) { |
161 |
fSessionLostHandler = new SessionLostHandler(this); |
170 |
if( numberOfConnections == 0 ) { |
162 |
notifyConnection(); |
171 |
fSessionLostHandler = new SessionLostHandler(this); |
163 |
Activator.trace("Telnet Service: Connected"); //$NON-NLS-1$ |
172 |
notifyConnection(); |
|
|
173 |
Activator.trace("Telnet Service: Connected"); //$NON-NLS-1$ |
174 |
} |
164 |
} else { |
175 |
} else { |
165 |
Activator.trace("Telnet Service: Connect failed"); //$NON-NLS-1$ |
176 |
Activator.trace("Telnet Service: Connect failed"); //$NON-NLS-1$ |
166 |
//TODO pass the nested exception as well as original prompts |
177 |
//TODO pass the nested exception as well as original prompts |
Lines 188-195
Link Here
|
188 |
try { |
199 |
try { |
189 |
if (fTelnetClient != null) { |
200 |
if (fTelnetClient != null) { |
190 |
synchronized (fTelnetClient) { |
201 |
synchronized (fTelnetClient) { |
191 |
if (fTelnetClient.isConnected()) |
202 |
if( numberOfConnections == 1) { |
192 |
fTelnetClient.disconnect(); |
203 |
if (fTelnetClient.isConnected()) |
|
|
204 |
fTelnetClient.disconnect(); |
205 |
}else { |
206 |
removeConnection(); |
207 |
} |
193 |
} |
208 |
} |
194 |
} |
209 |
} |
195 |
} catch (Exception e) { |
210 |
} catch (Exception e) { |
Lines 267-276
Link Here
|
267 |
notifyDisconnection(); |
282 |
notifyDisconnection(); |
268 |
} |
283 |
} |
269 |
|
284 |
|
|
|
285 |
public InputStream getSessionInputStream() { |
286 |
return this.in; |
287 |
} |
288 |
|
289 |
public OutputStream getSessionOutputStream() { |
290 |
return this.out; |
291 |
} |
292 |
public void setSessionPassword( String passwd ) { |
293 |
this.sessionPassword = passwd; |
294 |
} |
295 |
|
296 |
public String getSessionPassword() { |
297 |
return this.sessionPassword; |
298 |
} |
299 |
|
270 |
public TelnetClient getTelnetClient() { |
300 |
public TelnetClient getTelnetClient() { |
271 |
return fTelnetClient; |
301 |
return fTelnetClient; |
272 |
} |
302 |
} |
273 |
|
303 |
|
|
|
304 |
public void addConnection() { |
305 |
numberOfConnections++; |
306 |
} |
307 |
|
308 |
public void removeConnection() { |
309 |
numberOfConnections--; |
310 |
} |
311 |
|
312 |
public int getNumberOfConnections() { |
313 |
return numberOfConnections; |
314 |
|
315 |
} |
316 |
|
317 |
public void createNewConnection() { |
318 |
try { |
319 |
internalConnect( null ); |
320 |
} catch (Exception e) { |
321 |
SystemBasePlugin.logError(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), e); |
322 |
} |
323 |
} |
274 |
/** |
324 |
/** |
275 |
* Handle session-lost events. This is generic for any sort of connector |
325 |
* Handle session-lost events. This is generic for any sort of connector |
276 |
* service. Most of this is extracted from dstore's |
326 |
* service. Most of this is extracted from dstore's |