Mercurial > 510Connectbot
annotate src/com/five_ten_sg/connectbot/transport/AbsTransport.java @ 120:dcac61b6f2e6
add more 5250 config items
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 18 Jun 2014 18:57:19 -0700 |
parents | 77ac18bc1b2f |
children | 1350adb077b1 |
rev | line source |
---|---|
0 | 1 /* |
2 * ConnectBot: simple, powerful, open-source SSH client for Android | |
3 * Copyright 2007 Kenny Root, Jeffrey Sharkey | |
4 * | |
5 * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 * you may not use this file except in compliance with the License. | |
7 * You may obtain a copy of the License at | |
8 * | |
9 * http://www.apache.org/licenses/LICENSE-2.0 | |
10 * | |
11 * Unless required by applicable law or agreed to in writing, software | |
12 * distributed under the License is distributed on an "AS IS" BASIS, | |
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 * See the License for the specific language governing permissions and | |
15 * limitations under the License. | |
16 */ | |
17 | |
18 package com.five_ten_sg.connectbot.transport; | |
19 | |
20 import java.io.IOException; | |
21 import java.util.List; | |
22 import java.util.Map; | |
23 | |
24 import com.five_ten_sg.connectbot.bean.HostBean; | |
25 import com.five_ten_sg.connectbot.bean.PortForwardBean; | |
26 import com.five_ten_sg.connectbot.service.TerminalBridge; | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
27 import com.five_ten_sg.connectbot.service.TerminalKeyListener; |
0 | 28 import com.five_ten_sg.connectbot.service.TerminalManager; |
29 import android.content.Context; | |
30 import android.net.Uri; | |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
42
diff
changeset
|
31 import android.util.Log; |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
32 import de.mud.terminal.vt320; |
0 | 33 |
34 /** | |
35 * @author Kenny Root | |
36 * | |
37 */ | |
38 public abstract class AbsTransport { | |
44
959ebe0247b5
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
39 protected String TAG; |
959ebe0247b5
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
40 protected TerminalManager manager; |
959ebe0247b5
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
41 protected TerminalBridge bridge; |
91
33eb63352be5
remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents:
69
diff
changeset
|
42 protected String homeDirectory; |
44
959ebe0247b5
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
43 protected HostBean host; |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
44
diff
changeset
|
44 protected vt320 buffer = null; |
44
959ebe0247b5
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
45 protected String emulation; |
0 | 46 |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
47 class vt320Default extends vt320 { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
48 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
49 public void debug(String s) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
50 Log.d(TAG, s); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
51 } |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
52 |
100 | 53 // monitor injecting a field |
54 @Override | |
55 public void setField(int l, int c, char [] data) { | |
56 byte[] b = new byte[data.length]; | |
57 int i; | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
102
diff
changeset
|
58 |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
102
diff
changeset
|
59 for (i = 0; i < b.length; i++) { |
100 | 60 b[i] = (byte)(data[i] & 0x00ff); |
61 } | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
102
diff
changeset
|
62 |
102 | 63 write(b); |
100 | 64 } |
65 | |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
66 // terminal key listener sending to the host |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
67 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
68 public void write(byte[] b) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
69 try { |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
42
diff
changeset
|
70 if (bridge.monitor != null) bridge.monitor.hostData(b); |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
71 |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
42
diff
changeset
|
72 AbsTransport.this.write(b); |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
73 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
74 catch (IOException e) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
75 Log.e(TAG, "Problem writing outgoing data in vt320() thread", e); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
76 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
77 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
78 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
79 public void write(int b) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
80 try { |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
42
diff
changeset
|
81 if (bridge.monitor != null) bridge.monitor.hostData(b); |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
82 |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
42
diff
changeset
|
83 AbsTransport.this.write(b); |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
84 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
85 catch (IOException e) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
86 Log.e(TAG, "Problem writing outgoing data in vt320() thread", e); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
87 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
88 } |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
89 |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
90 // We don't use telnet sequences. |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
91 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
92 public void sendTelnetCommand(byte cmd) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
93 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
94 // We don't want remote to resize our window. |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
95 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
96 public void setWindowSize(int c, int r) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
97 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
98 // play beep noise |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
99 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
100 public void beep() { |
47
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
101 if ((bridge.parent != null) && (bridge.parent.isShown())) |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
102 manager.playBeep(); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
103 else |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
104 manager.sendActivityNotification(host); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
105 } |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
106 |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
107 // test for changed screen contents |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
108 @Override |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
109 public void testChanged() { |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
110 if (bridge.monitor != null) bridge.monitor.testChanged(); |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
111 } |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
112 // relay socket writing to the screen |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
113 // bridge.monitor placement of new characters |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
114 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
115 public void putChar(int c, int l, char ch, int attributes) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
116 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
117 |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
118 super.putChar(c, l, ch, attributes); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
119 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
120 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
121 public void insertChar(int c, int l, char ch, int attributes) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
122 if (bridge.monitor != null) bridge.monitor.screenChanged(l, l, c, width - 1); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
123 |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
124 super.insertChar(c, l, ch, attributes); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
125 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
126 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
127 public void insertLine(int l, int n, boolean scrollDown) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
128 if (bridge.monitor != null) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
129 if (scrollDown) bridge.monitor.screenChanged(l, height - 1, 0, width - 1); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
130 else bridge.monitor.screenChanged(0, l, 0, width - 1); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
131 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
132 |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
133 super.insertLine(l, n, scrollDown); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
134 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
135 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
136 public void deleteLine(int l) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
137 if (bridge.monitor != null) bridge.monitor.screenChanged(l, height - 1, 0, width - 1); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
138 |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
139 super.deleteLine(l); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
140 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
141 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
142 public void deleteChar(int c, int l) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
143 if (bridge.monitor != null) bridge.monitor.screenChanged(l, l, c, width - 1); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
144 |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
145 super.deleteChar(c, l); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
146 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
147 @Override |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
148 public void setCursorPosition(int c, int l) { |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
149 if (bridge.monitor != null) bridge.monitor.cursorMove(l, c); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
150 |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
151 super.setCursorPosition(c, l); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
152 } |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
153 |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
154 // monitor setField() |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
155 |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
156 }; |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
157 |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
158 |
0 | 159 public AbsTransport() {} |
160 | |
161 /** | |
162 * @return protocol part of the URI | |
163 */ | |
164 public static String getProtocolName() { | |
165 return "unknown"; | |
166 } | |
167 | |
168 /** | |
169 * Encode the current transport into a URI that can be passed via intent calls. | |
170 * @return URI to host | |
171 */ | |
11 | 172 public abstract Uri getUri(String input); |
173 | |
0 | 174 |
175 /** | |
176 * Causes transport to connect to the target host. After connecting but before a | |
177 * session is started, must call back to {@link TerminalBridge#onConnected()}. | |
178 * After that call a session may be opened. | |
179 */ | |
180 public abstract void connect(); | |
181 | |
182 /** | |
183 * Checks if read() will block. If there are no bytes remaining in | |
184 * the underlying transport, return true. | |
185 */ | |
186 public abstract boolean willBlock(); | |
187 | |
188 /** | |
189 * Reads from the transport. Transport must support reading into a byte array | |
190 * <code>buffer</code> at the start of <code>offset</code> and a maximum of | |
191 * <code>length</code> bytes. If the remote host disconnects, throw an | |
192 * {@link IOException}. | |
193 * @param buffer byte buffer to store read bytes into | |
194 * @param offset where to start writing in the buffer | |
195 * @param length maximum number of bytes to read | |
196 * @return number of bytes read | |
197 * @throws IOException when remote host disconnects | |
198 */ | |
199 public abstract int read(byte[] buffer, int offset, int length) throws IOException; | |
200 | |
201 /** | |
202 * Writes to the transport. If the host is not yet connected, simply return without | |
203 * doing anything. An {@link IOException} should be thrown if there is an error after | |
204 * connection. | |
205 * @param buffer bytes to write to transport | |
206 * @throws IOException when there is a problem writing after connection | |
207 */ | |
208 public abstract void write(byte[] buffer) throws IOException; | |
209 | |
210 /** | |
211 * Writes to the transport. See {@link #write(byte[])} for behavior details. | |
212 * @param c character to write to the transport | |
213 * @throws IOException when there is a problem writing after connection | |
214 */ | |
215 public abstract void write(int c) throws IOException; | |
216 | |
217 /** | |
218 * Flushes the write commands to the transport. | |
219 * @throws IOException when there is a problem writing after connection | |
220 */ | |
221 public abstract void flush() throws IOException; | |
222 | |
223 /** | |
224 * Closes the connection to the terminal. Note that the resulting failure to read | |
225 * should call {@link TerminalBridge#dispatchDisconnect(boolean)}. | |
226 */ | |
227 public abstract void close(); | |
228 | |
229 /** | |
230 * Tells the transport what dimensions the display is currently | |
231 * @param columns columns of text | |
232 * @param rows rows of text | |
233 * @param width width in pixels | |
234 * @param height height in pixels | |
235 */ | |
236 public abstract void setDimensions(int columns, int rows, int width, int height); | |
237 | |
238 public void setOptions(Map<String, String> options) { | |
239 // do nothing | |
240 } | |
241 | |
242 public Map<String, String> getOptions() { | |
243 return null; | |
244 } | |
245 | |
246 public void setCompression(boolean compression) { | |
247 // do nothing | |
248 } | |
249 | |
250 public void setHttpproxy(String httpproxy) { | |
251 // do nothing | |
252 } | |
253 | |
254 public void setUseAuthAgent(String useAuthAgent) { | |
255 // do nothing | |
256 } | |
257 | |
258 public String getEmulation() { | |
259 return emulation; | |
260 } | |
261 | |
47
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
262 protected vt320 setupTransportBuffer() { |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
263 int scrollback = (host.getWantSession()) ? manager.getScrollback() : 0; |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
264 buffer.setBufferSize(scrollback); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
265 buffer.setDisplay(bridge); |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
266 return buffer; |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
267 } |
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
268 |
47
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
269 public vt320 getTransportBuffer() { |
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
270 buffer = new vt320Default(); |
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
271 return setupTransportBuffer(); |
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
272 } |
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
273 |
91
33eb63352be5
remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents:
69
diff
changeset
|
274 public void setLinks(TerminalManager manager, TerminalBridge bridge, String homeDirectory, HostBean host, String emulation) { |
33eb63352be5
remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents:
69
diff
changeset
|
275 this.manager = manager; |
33eb63352be5
remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents:
69
diff
changeset
|
276 this.bridge = bridge; |
33eb63352be5
remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents:
69
diff
changeset
|
277 this.homeDirectory = homeDirectory; |
33eb63352be5
remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents:
69
diff
changeset
|
278 this.host = host; |
33eb63352be5
remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents:
69
diff
changeset
|
279 this.emulation = emulation; |
0 | 280 } |
281 | |
282 /** | |
283 * Whether or not this transport type can forward ports. | |
284 * @return true on ability to forward ports | |
285 */ | |
286 public boolean canForwardPorts() { | |
287 return false; | |
288 } | |
289 | |
290 /** | |
291 * Adds the {@link PortForwardBean} to the list. | |
292 * @param portForward the port forward bean to add | |
293 * @return true on successful addition | |
294 */ | |
295 public boolean addPortForward(PortForwardBean portForward) { | |
296 return false; | |
297 } | |
298 | |
299 /** | |
300 * Enables a port forward member. After calling this method, the port forward should | |
301 * be operational iff it could be enabled by the transport. | |
302 * @param portForward member of our current port forwards list to enable | |
303 * @return true on successful port forward setup | |
304 */ | |
305 public boolean enablePortForward(PortForwardBean portForward) { | |
306 return false; | |
307 } | |
308 | |
309 /** | |
310 * Disables a port forward member. After calling this method, the port forward should | |
311 * be non-functioning iff it could be disabled by the transport. | |
312 * @param portForward member of our current port forwards list to enable | |
313 * @return true on successful port forward tear-down | |
314 */ | |
315 public boolean disablePortForward(PortForwardBean portForward) { | |
316 return false; | |
317 } | |
318 | |
319 /** | |
320 * Removes the {@link PortForwardBean} from the available port forwards. | |
321 * @param portForward the port forward bean to remove | |
322 * @return true on successful removal | |
323 */ | |
324 public boolean removePortForward(PortForwardBean portForward) { | |
325 return false; | |
326 } | |
327 | |
328 /** | |
329 * Gets a list of the {@link PortForwardBean} currently used by this transport. | |
330 * @return the list of port forwards | |
331 */ | |
332 public List<PortForwardBean> getPortForwards() { | |
333 return null; | |
334 } | |
335 | |
336 /** | |
337 * Whether or not this transport type can transfer files. | |
338 * @return true on ability to transfer files | |
339 */ | |
340 public boolean canTransferFiles() { | |
341 return false; | |
342 } | |
343 | |
344 /** | |
345 * Downloads the specified remote file to a local folder. | |
346 * @param remoteFile The path to the remote file to be downloaded. Must be non-null. | |
347 * @param localFolder The path to local folder. Null = default external storage folder. | |
348 * @return true on success, false on failure | |
349 */ | |
350 public boolean downloadFile(String remoteFile, String localFolder) { | |
351 return false; | |
352 } | |
353 | |
354 /** | |
355 * Uploads the specified local file to the remote host. | |
356 * @param localFile The path to the local file to be uploaded. Must be non-null. | |
357 * @param remoteFolder The path to the remote directory. Null == default remote directory. | |
358 * @return true on success, false on failure | |
359 */ | |
360 public boolean uploadFile(String localFile, String remoteFile, | |
361 String remoteFolder, String mode) { | |
362 return false; | |
363 } | |
364 | |
365 | |
366 /** | |
367 * @return int default port for protocol | |
368 */ | |
369 public abstract int getDefaultPort(); | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
370 public abstract boolean isConnected(); |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
371 public abstract boolean isSessionOpen(); |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
372 public abstract boolean isAuthenticated(); |
0 | 373 |
374 /** | |
375 * @param username | |
376 * @param hostname | |
377 * @param port | |
378 * @return | |
379 */ | |
380 public abstract String getDefaultNickname(String username, String hostname, int port); | |
381 | |
382 /** | |
383 * @param uri | |
384 * @param selectionKeys | |
385 * @param selectionValues | |
386 */ | |
387 public abstract void getSelectionArgs(Uri uri, Map<String, String> selection); | |
388 | |
389 /** | |
390 * @param uri | |
391 * @return | |
392 */ | |
393 public abstract HostBean createHost(Uri uri); | |
394 | |
395 /** | |
396 * @param context context containing the correct resources | |
397 * @return string that hints at the format for connection | |
398 */ | |
11 | 399 public abstract String getFormatHint(Context context); |
0 | 400 |
401 /** | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
402 * @return do we use the network |
0 | 403 */ |
404 public abstract boolean usesNetwork(); | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
405 |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
406 /** |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
407 * @return do we need a relay object to read from the transport |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
408 * and send the data into the vt320 buffer |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
409 */ |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
410 public boolean needsRelay() { |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
411 return true; |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
412 } |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
413 |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
414 /** |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
415 * @return a key listener |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
416 */ |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
417 public TerminalKeyListener getTerminalKeyListener() { |
42
7ac846a07ed4
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
418 return new TerminalKeyListener(manager, bridge, buffer, host.getEncoding()); |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
419 } |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
11
diff
changeset
|
420 |
0 | 421 } |