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