Mercurial > 510Connectbot
annotate src/com/five_ten_sg/connectbot/transport/TN5250.java @ 184:cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 02 Jul 2014 14:32:13 -0700 |
parents | 2a7199ad90be |
children | c51bcf9f0516 |
rev | line source |
---|---|
11 | 1 /* |
2 * 510ConnectBot | |
3 * Copyright 2014 Carl Byington | |
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.io.InputStream; | |
22 import java.io.OutputStream; | |
23 import java.net.Socket; | |
24 import java.net.SocketException; | |
13 | 25 import java.net.UnknownHostException; |
54
a7e660661e08
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
53
diff
changeset
|
26 import java.util.HashMap; |
11 | 27 import java.util.List; |
28 import java.util.Map; | |
13 | 29 import java.util.regex.Matcher; |
30 import java.util.regex.Pattern; | |
11 | 31 |
12 | 32 import org.tn5250j.framework.tn5250.Screen5250; |
33 import org.tn5250j.framework.tn5250.tnvt; | |
34 | |
13 | 35 import com.five_ten_sg.connectbot.R; |
11 | 36 import com.five_ten_sg.connectbot.bean.HostBean; |
37 import com.five_ten_sg.connectbot.bean.PortForwardBean; | |
38 import com.five_ten_sg.connectbot.service.TerminalBridge; | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
39 import com.five_ten_sg.connectbot.service.TerminalKeyListener; |
11 | 40 import com.five_ten_sg.connectbot.service.TerminalManager; |
41 import com.five_ten_sg.connectbot.util.HostDatabase; | |
50
2cd3d8091e37
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
49
diff
changeset
|
42 import com.five_ten_sg.connectbot.util.PreferenceConstants; |
11 | 43 import android.content.Context; |
44 import android.net.Uri; | |
13 | 45 import android.util.Log; |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
46 import android.view.KeyCharacterMap; |
50
2cd3d8091e37
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
49
diff
changeset
|
47 import android.view.KeyEvent; |
2cd3d8091e37
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
49
diff
changeset
|
48 import android.view.View; |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
49 import de.mud.terminal.vt320; |
11 | 50 |
51 | |
52 /** | |
53 * @author Carl Byington | |
54 * | |
55 */ | |
56 public class TN5250 extends AbsTransport { | |
57 private static final String PROTOCOL = "tn5250"; | |
58 private static final String TAG = "ConnectBot.tn5250"; | |
59 private static final int DEFAULT_PORT = 23; | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
60 |
11 | 61 private Screen5250 screen52; |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
62 private tnvt handler = null; |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
63 private Socket socket; |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
64 private boolean connected = false; |
11 | 65 |
12 | 66 static final Pattern hostmask; |
67 static { | |
68 hostmask = Pattern.compile("^([0-9a-z.-]+)(:(\\d+))?$", Pattern.CASE_INSENSITIVE); | |
69 } | |
70 | |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
71 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
72 class vt320x5250 extends vt320 { |
84
8f23b05a51f7
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
71
diff
changeset
|
73 private HashMap<Integer, Integer> controls; |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
74 private HashMap<Integer, String> mnemonics; |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
75 |
54
a7e660661e08
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
53
diff
changeset
|
76 public vt320x5250() { |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
77 this(80, 24); |
54
a7e660661e08
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
53
diff
changeset
|
78 } |
a7e660661e08
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
53
diff
changeset
|
79 |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
80 public vt320x5250(int width, int height) { |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
81 super(width, height); |
84
8f23b05a51f7
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
71
diff
changeset
|
82 controls = new HashMap<Integer, Integer>(); |
166
9d6b581b4656
add ctrl keys for attn and sysreq
Carl Byington <carl@five-ten-sg.com>
parents:
164
diff
changeset
|
83 controls.put(0x01, KEY_PAUSE); // ctrl-a -> [attn] |
84
8f23b05a51f7
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
71
diff
changeset
|
84 controls.put(0x08, KEY_BACK_SPACE); |
8f23b05a51f7
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
71
diff
changeset
|
85 controls.put(0x09, KEY_TAB); |
8f23b05a51f7
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
71
diff
changeset
|
86 controls.put(0x0d, KEY_ENTER); |
166
9d6b581b4656
add ctrl keys for attn and sysreq
Carl Byington <carl@five-ten-sg.com>
parents:
164
diff
changeset
|
87 controls.put(0x12, KEY_ESCAPE); // ctrl-r -> [reset] |
9d6b581b4656
add ctrl keys for attn and sysreq
Carl Byington <carl@five-ten-sg.com>
parents:
164
diff
changeset
|
88 controls.put(0x13, KEY_SYSREQ); // ctrl-s -> [sysreq] |
9d6b581b4656
add ctrl keys for attn and sysreq
Carl Byington <carl@five-ten-sg.com>
parents:
164
diff
changeset
|
89 controls.put(0x1b, KEY_ESCAPE); // esc -> [reset] |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
90 mnemonics = new HashMap<Integer, String>(); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
91 mnemonics.put(KEY_PAUSE , "[attn]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
92 mnemonics.put(KEY_F1 , "[pf1]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
93 mnemonics.put(KEY_F2 , "[pf2]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
94 mnemonics.put(KEY_F3 , "[pf3]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
95 mnemonics.put(KEY_F4 , "[pf4]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
96 mnemonics.put(KEY_F5 , "[pf5]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
97 mnemonics.put(KEY_F6 , "[pf6]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
98 mnemonics.put(KEY_F7 , "[pf7]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
99 mnemonics.put(KEY_F8 , "[pf8]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
100 mnemonics.put(KEY_F9 , "[pf9]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
101 mnemonics.put(KEY_F10 , "[pf10]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
102 mnemonics.put(KEY_F11 , "[pf11]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
103 mnemonics.put(KEY_F12 , "[pf12]"); |
175
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
104 mnemonics.put(KEY_F13 , "[pf13]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
105 mnemonics.put(KEY_F14 , "[pf14]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
106 mnemonics.put(KEY_F15 , "[pf15]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
107 mnemonics.put(KEY_F16 , "[pf16]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
108 mnemonics.put(KEY_F17 , "[pf17]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
109 mnemonics.put(KEY_F18 , "[pf18]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
110 mnemonics.put(KEY_F19 , "[pf19]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
111 mnemonics.put(KEY_F20 , "[pf20]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
112 mnemonics.put(KEY_F21 , "[pf21]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
113 mnemonics.put(KEY_F22 , "[pf22]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
114 mnemonics.put(KEY_F23 , "[pf23]"); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
115 mnemonics.put(KEY_F24 , "[pf24]"); |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
116 mnemonics.put(KEY_UP , "[up]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
117 mnemonics.put(KEY_DOWN , "[down]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
118 mnemonics.put(KEY_LEFT , "[left]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
119 mnemonics.put(KEY_RIGHT , "[right]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
120 mnemonics.put(KEY_PAGE_DOWN , "[pgdown]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
121 mnemonics.put(KEY_PAGE_UP , "[pgup]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
122 mnemonics.put(KEY_INSERT , "[insert]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
123 mnemonics.put(KEY_DELETE , "[delete]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
124 mnemonics.put(KEY_BACK_SPACE , "[backspace]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
125 mnemonics.put(KEY_HOME , "[home]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
126 mnemonics.put(KEY_END , "[end]"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
127 mnemonics.put(KEY_NUM_LOCK , ""); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
128 mnemonics.put(KEY_CAPS_LOCK , ""); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
129 mnemonics.put(KEY_SHIFT , ""); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
130 mnemonics.put(KEY_CONTROL , ""); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
131 mnemonics.put(KEY_ALT , ""); |
57
e0c68988fe2e
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
54
diff
changeset
|
132 mnemonics.put(KEY_ENTER , "[enter]"); |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
133 mnemonics.put(KEY_NUMPAD0 , "0"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
134 mnemonics.put(KEY_NUMPAD1 , "1"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
135 mnemonics.put(KEY_NUMPAD2 , "2"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
136 mnemonics.put(KEY_NUMPAD3 , "3"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
137 mnemonics.put(KEY_NUMPAD4 , "4"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
138 mnemonics.put(KEY_NUMPAD5 , "5"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
139 mnemonics.put(KEY_NUMPAD6 , "6"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
140 mnemonics.put(KEY_NUMPAD7 , "7"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
141 mnemonics.put(KEY_NUMPAD8 , "8"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
142 mnemonics.put(KEY_NUMPAD9 , "9"); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
143 mnemonics.put(KEY_DECIMAL , "."); |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
144 mnemonics.put(KEY_ADD , "+"); |
151 | 145 mnemonics.put(KEY_ESCAPE , "[reset]"); |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
146 mnemonics.put(KEY_TAB , "[tab]"); |
166
9d6b581b4656
add ctrl keys for attn and sysreq
Carl Byington <carl@five-ten-sg.com>
parents:
164
diff
changeset
|
147 mnemonics.put(KEY_SYSREQ , "[sysreq]"); |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
148 } |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
149 |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
150 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
151 public void debug(String s) { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
152 Log.d(TAG, s); |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
153 } |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
154 |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
155 // monitor injecting a field |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
156 @Override |
104
171e0a977544
cleanup keystroke handling
Carl Byington <carl@five-ten-sg.com>
parents:
91
diff
changeset
|
157 public void setField(int l, int c, char [] data) { |
171e0a977544
cleanup keystroke handling
Carl Byington <carl@five-ten-sg.com>
parents:
91
diff
changeset
|
158 screen52.setField(l, c, data); |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
159 } |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
160 |
175
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
161 // monitor simulating key depress |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
162 @Override |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
163 public void keyDepressed(int keyCode, char keyChar, int modifiers) { |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
164 if (mnemonics.containsKey(keyCode)) { |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
165 String s = mnemonics.get(keyCode); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
166 if (s != "") screen52.sendKeys(s); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
167 } |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
168 } |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
169 |
148
69333ca1563c
add ptt button p2 preference
Carl Byington <carl@five-ten-sg.com>
parents:
147
diff
changeset
|
170 // 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
|
171 @Override |
69333ca1563c
add ptt button p2 preference
Carl Byington <carl@five-ten-sg.com>
parents:
147
diff
changeset
|
172 public void monitorKey(boolean down) { |
69333ca1563c
add ptt button p2 preference
Carl Byington <carl@five-ten-sg.com>
parents:
147
diff
changeset
|
173 if (bridge.monitor != null) bridge.monitor.keyState(down); |
69333ca1563c
add ptt button p2 preference
Carl Byington <carl@five-ten-sg.com>
parents:
147
diff
changeset
|
174 } |
69333ca1563c
add ptt button p2 preference
Carl Byington <carl@five-ten-sg.com>
parents:
147
diff
changeset
|
175 |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
176 // terminal key listener sending to local screen |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
177 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
178 public void write(byte[] b) { |
144 | 179 screen52.sendKeys(new String(b)); |
175
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
180 testChanged(); |
144 | 181 } |
182 @Override | |
183 public void write(int b) { | |
184
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
184 if (b == 120) { |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
185 // special case x for testing |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
186 setField(17, 44, new char[] { '1', '2' }); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
187 keyPressed(KEY_TAB, ' ', 0); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
188 keyPressed(KEY_TAB, ' ', 0); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
189 setField(-1, -1, new char[] { '3', '4' }); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
190 setField(18, 44, new char[0]); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
191 setField(-1, -1, new char[] { '5', '6' }); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
192 return; |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
193 } |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
194 if (b == 121) { |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
195 // special case y for testing |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
196 setField(17, 44, new char[0]); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
197 setField(-1, -1, new char[] { '2', '1' }); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
198 keyPressed(KEY_TAB, ' ', 0); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
199 keyPressed(KEY_TAB, ' ', 0); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
200 setField(-1, -1, new char[] { '4', '3' }); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
201 setField(18, 44, new char[0]); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
202 setField(-1, -1, new char[] { '6', '5' }); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
203 return; |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
204 } |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
205 if (b == 122) { |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
206 // special case z for testing |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
207 setField(17, 40, new char[0]); |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
208 return; |
cdaaa53b5eca
setfield positions the cursor properly as if the characters were typed
Carl Byington <carl@five-ten-sg.com>
parents:
175
diff
changeset
|
209 } |
147
1350adb077b1
monitor key state tracking
Carl Byington <carl@five-ten-sg.com>
parents:
145
diff
changeset
|
210 if (controls.containsKey(b)) keyPressed(controls.get(b), ' ', 0); |
1350adb077b1
monitor key state tracking
Carl Byington <carl@five-ten-sg.com>
parents:
145
diff
changeset
|
211 else screen52.sendKeys(new String(new byte[] {(byte)b})); |
175
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
212 testChanged(); |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
213 } |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
214 @Override |
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
215 public void keyPressed(int keyCode, char keyChar, int modifiers) { |
175
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
216 keyDepressed(keyCode, keyChar, modifiers); |
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
217 testChanged(); |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
218 } |
175
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
166
diff
changeset
|
219 |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
220 // 5250 writing to the screen |
69
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
221 // test for changed screen contents |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
222 @Override |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
223 public void testChanged() { |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
224 if (bridge.monitor != null) bridge.monitor.testChanged(); |
294435151b0c
use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents:
68
diff
changeset
|
225 } |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
226 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
227 public void putChar(int c, int l, char ch, int attributes) { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
228 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c); |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
229 |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
230 super.putChar(c, l, ch, attributes); |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
231 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
232 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
233 public void setCursorPosition(int c, int l) { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
234 if (bridge.monitor != null) bridge.monitor.cursorMove(l, c); |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
235 |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
236 super.setCursorPosition(c, l); |
87
1bc2229562f8
convert ctrl keys to virtual keys; use proper android home directory
Carl Byington <carl@five-ten-sg.com>
parents:
84
diff
changeset
|
237 redraw(); |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
238 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
239 }; |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
240 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
241 |
11 | 242 public TN5250() { |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
243 super(); |
53
e872762ec105
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
52
diff
changeset
|
244 } |
11 | 245 |
246 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
247 /** |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
248 * @return protocol part of the URI |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
249 */ |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
250 public static String getProtocolName() { |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
251 return PROTOCOL; |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
252 } |
11 | 253 |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
254 |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
255 /** |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
256 * Encode the current transport into a URI that can be passed via intent calls. |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
257 * @return URI to host |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
258 */ |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
259 public Uri getUri(String input) { |
12 | 260 Matcher matcher = hostmask.matcher(input); |
261 | |
262 if (!matcher.matches()) | |
263 return null; | |
264 | |
265 StringBuilder sb = new StringBuilder(); | |
266 sb.append(PROTOCOL) | |
267 .append("://") | |
268 .append(matcher.group(1)); | |
269 String portString = matcher.group(3); | |
270 int port = DEFAULT_PORT; | |
271 | |
272 if (portString != null) { | |
273 try { | |
274 port = Integer.parseInt(portString); | |
275 | |
276 if (port < 1 || port > 65535) { | |
277 port = DEFAULT_PORT; | |
278 } | |
279 } | |
280 catch (NumberFormatException nfe) { | |
281 // Keep the default port | |
282 } | |
283 } | |
284 | |
285 if (port != DEFAULT_PORT) { | |
286 sb.append(':'); | |
287 sb.append(port); | |
288 } | |
289 | |
290 sb.append("/#") | |
291 .append(Uri.encode(input)); | |
292 Uri uri = Uri.parse(sb.toString()); | |
293 return uri; | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
294 } |
11 | 295 |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
296 |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
297 /** |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
298 * Causes transport to connect to the target host. After connecting but before a |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
299 * session is started, must call back to {@link TerminalBridge#onConnected()}. |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
300 * After that call a session may be opened. |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
301 */ |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
302 @Override |
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
104
diff
changeset
|
303 public void connect() { |
30
d738f6b876fe
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
29
diff
changeset
|
304 screen52 = new Screen5250(); |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
305 handler = new tnvt(screen52, true, false, bridge, manager); |
32
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
306 screen52.setVT(handler); |
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
307 screen52.setBuffer(buffer); |
140
4fe73e73d4d7
fill vt320 buffer from tn5250 buffer when font size shrinks
Carl Byington <carl@five-ten-sg.com>
parents:
133
diff
changeset
|
308 bridge.addFontSizeChangedListener(screen52); |
121
477cca1e0c15
add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
309 connected = handler.connect(host, homeDirectory, buffer); |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
310 if (connected) bridge.onConnected(); |
11 | 311 } |
312 | |
313 | |
314 /** | |
315 * Checks if read() will block. If there are no bytes remaining in | |
316 * the underlying transport, return true. | |
317 */ | |
318 @Override | |
319 public boolean willBlock() { | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
320 // we don't use a relay thread between the transport and the vt320 buffer |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
321 return true; |
11 | 322 } |
323 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
324 |
11 | 325 /** |
326 * Reads from the transport. Transport must support reading into a byte array | |
327 * <code>buffer</code> at the start of <code>offset</code> and a maximum of | |
328 * <code>length</code> bytes. If the remote host disconnects, throw an | |
329 * {@link IOException}. | |
330 * @param buffer byte buffer to store read bytes into | |
331 * @param offset where to start writing in the buffer | |
332 * @param length maximum number of bytes to read | |
333 * @return number of bytes read | |
334 * @throws IOException when remote host disconnects | |
335 */ | |
336 public int read(byte[] buffer, int offset, int length) throws IOException { | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
337 // we don't use a relay thread between the transport and the vt320 buffer |
11 | 338 return 0; |
339 } | |
340 | |
341 | |
342 /** | |
343 * Writes to the transport. If the host is not yet connected, simply return without | |
344 * doing anything. An {@link IOException} should be thrown if there is an error after | |
345 * connection. | |
346 * @param buffer bytes to write to transport | |
347 * @throws IOException when there is a problem writing after connection | |
348 */ | |
349 public void write(byte[] buffer) throws IOException { | |
350 } | |
351 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
352 |
11 | 353 /** |
354 * Writes to the transport. See {@link #write(byte[])} for behavior details. | |
355 * @param c character to write to the transport | |
356 * @throws IOException when there is a problem writing after connection | |
357 */ | |
358 public void write(int c) throws IOException { | |
359 } | |
360 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
361 |
11 | 362 /** |
363 * Flushes the write commands to the transport. | |
364 * @throws IOException when there is a problem writing after connection | |
365 */ | |
366 public void flush() throws IOException { | |
367 } | |
368 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
369 |
11 | 370 /** |
32
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
371 * Closes the connection to the terminal. |
11 | 372 */ |
373 public void close() { | |
13 | 374 handler.disconnect(); |
11 | 375 connected = false; |
140
4fe73e73d4d7
fill vt320 buffer from tn5250 buffer when font size shrinks
Carl Byington <carl@five-ten-sg.com>
parents:
133
diff
changeset
|
376 bridge.removeFontSizeChangedListener(screen52); |
32
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
377 bridge.dispatchDisconnect(false); |
11 | 378 } |
379 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
380 |
11 | 381 /** |
382 * Tells the transport what dimensions the display is currently | |
383 * @param columns columns of text | |
384 * @param rows rows of text | |
385 * @param width width in pixels | |
386 * @param height height in pixels | |
387 */ | |
388 @Override | |
389 public void setDimensions(int columns, int rows, int width, int height) { | |
390 // do nothing | |
391 } | |
392 | |
393 | |
394 @Override | |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
395 public vt320 getTransportBuffer() { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
396 buffer = new vt320x5250(); |
47
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
46
diff
changeset
|
397 return setupTransportBuffer(); |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
398 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
399 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
400 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
401 @Override |
11 | 402 public int getDefaultPort() { |
403 return DEFAULT_PORT; | |
404 } | |
405 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
406 |
11 | 407 @Override |
408 public boolean isConnected() { | |
409 return connected; | |
410 } | |
411 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
412 |
11 | 413 @Override |
414 public boolean isSessionOpen() { | |
415 return connected; | |
416 } | |
417 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
418 |
11 | 419 @Override |
420 public boolean isAuthenticated() { | |
421 return connected; | |
422 } | |
423 | |
424 | |
425 @Override | |
426 public String getDefaultNickname(String username, String hostname, int port) { | |
427 if (port == DEFAULT_PORT) { | |
428 return String.format("%s", hostname); | |
429 } | |
430 else { | |
431 return String.format("%s:%d", hostname, port); | |
432 } | |
433 } | |
434 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
435 |
11 | 436 @Override |
437 public void getSelectionArgs(Uri uri, Map<String, String> selection) { | |
438 selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL); | |
439 selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment()); | |
440 selection.put(HostDatabase.FIELD_HOST_HOSTNAME, uri.getHost()); | |
441 int port = uri.getPort(); | |
442 | |
147
1350adb077b1
monitor key state tracking
Carl Byington <carl@five-ten-sg.com>
parents:
145
diff
changeset
|
443 if (port < 0) port = DEFAULT_PORT; |
11 | 444 |
445 selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port)); | |
446 } | |
447 | |
448 | |
449 @Override | |
450 public HostBean createHost(Uri uri) { | |
451 HostBean host = new HostBean(); | |
452 host.setProtocol(PROTOCOL); | |
453 host.setHostname(uri.getHost()); | |
454 int port = uri.getPort(); | |
455 | |
147
1350adb077b1
monitor key state tracking
Carl Byington <carl@five-ten-sg.com>
parents:
145
diff
changeset
|
456 if (port < 0) port = DEFAULT_PORT; |
11 | 457 |
458 host.setPort(port); | |
459 String nickname = uri.getFragment(); | |
460 | |
461 if (nickname == null || nickname.length() == 0) { | |
133
b151d3eca95a
read deployment.connections on startup for new host entries
Carl Byington <carl@five-ten-sg.com>
parents:
132
diff
changeset
|
462 nickname = getDefaultNickname(host.getUsername(), host.getHostname(), host.getPort()); |
11 | 463 } |
132
265a4733edcb
read deployment.connections on startup for new host entries
Carl Byington <carl@five-ten-sg.com>
parents:
121
diff
changeset
|
464 host.setNickname(nickname); |
11 | 465 |
466 return host; | |
467 } | |
468 | |
469 | |
12 | 470 public String getFormatHint(Context context) { |
11 | 471 return String.format("%s:%s", |
472 context.getString(R.string.format_hostname), | |
473 context.getString(R.string.format_port)); | |
474 } | |
475 | |
476 | |
477 @Override | |
478 public boolean usesNetwork() { | |
479 return true; | |
480 } | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
481 |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
482 |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
483 @Override |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
484 public boolean needsRelay() { |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
485 // we don't use a relay thread between the transport and the vt320 buffer |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
486 return false; |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
487 } |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
488 |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
489 public TerminalKeyListener getTerminalKeyListener() { |
145
4dfa4dd791c1
testing setfield functions
Carl Byington <carl@five-ten-sg.com>
parents:
144
diff
changeset
|
490 return new TerminalKeyListener(manager, bridge, buffer, host.getEncoding()); |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
491 } |
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
492 |
11 | 493 } |