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