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