Mercurial > 510Connectbot
annotate src/com/five_ten_sg/connectbot/transport/TN5250.java @ 49:8887bff45dee tn5250
start tn5250 integration
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 11 Jun 2014 11:28:31 -0700 |
parents | a3fd10a8c0de |
children | 2cd3d8091e37 |
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; |
11 | 26 import java.util.List; |
27 import java.util.Map; | |
13 | 28 import java.util.regex.Matcher; |
29 import java.util.regex.Pattern; | |
11 | 30 |
12 | 31 import org.tn5250j.framework.tn5250.Screen5250; |
32 import org.tn5250j.framework.tn5250.tnvt; | |
33 | |
13 | 34 import com.five_ten_sg.connectbot.R; |
11 | 35 import com.five_ten_sg.connectbot.bean.HostBean; |
36 import com.five_ten_sg.connectbot.bean.PortForwardBean; | |
37 import com.five_ten_sg.connectbot.service.TerminalBridge; | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
38 import com.five_ten_sg.connectbot.service.TerminalKeyListener; |
11 | 39 import com.five_ten_sg.connectbot.service.TerminalManager; |
40 import com.five_ten_sg.connectbot.util.HostDatabase; | |
41 import android.content.Context; | |
42 import android.net.Uri; | |
13 | 43 import android.util.Log; |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
44 import de.mud.terminal.vt320; |
11 | 45 |
46 | |
47 /** | |
48 * @author Carl Byington | |
49 * | |
50 */ | |
51 public class TN5250 extends AbsTransport { | |
52 private static final String PROTOCOL = "tn5250"; | |
53 private static final String TAG = "ConnectBot.tn5250"; | |
54 private static final int DEFAULT_PORT = 23; | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
55 |
11 | 56 private Screen5250 screen52; |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
57 private tnvt handler = null; |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
58 private Socket socket; |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
59 private boolean connected = false; |
11 | 60 |
12 | 61 static final Pattern hostmask; |
62 static { | |
63 hostmask = Pattern.compile("^([0-9a-z.-]+)(:(\\d+))?$", Pattern.CASE_INSENSITIVE); | |
64 } | |
65 | |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
66 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
67 class vt320x5250 extends vt320 { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
68 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
69 public void debug(String s) { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
70 Log.d(TAG, s); |
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 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
73 public void write(byte[] b) { |
49
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
74 screen52.sendKeys(new String(b)); |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
75 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
76 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
77 public void write(int b) { |
49
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
78 screen52.sendKeys(new String(new byte[] {b})); |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
79 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
80 // bridge.monitor placement of new characters |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
81 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
82 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
|
83 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c); |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
84 super.putChar(c, l, ch, attributes); |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
85 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
86 @Override |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
87 public void setCursorPosition(int c, int l) { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
88 if (bridge.monitor != null) bridge.monitor.cursorMove(l, c); |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
89 super.setCursorPosition(c, l); |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
90 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
91 }; |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
92 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
93 |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
94 class Terminal5250KeyListener extends TerminalKeyListener { |
46
34ce32c4e807
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
95 public Terminal5250KeyListener(TerminalManager manager, |
34ce32c4e807
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
96 TerminalBridge bridge, |
34ce32c4e807
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
97 vt320 buffer, |
34ce32c4e807
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
45
diff
changeset
|
98 String encoding) { |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
99 super(manager, bridge, buffer, encoding); |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
100 } |
49
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
101 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
102 /** |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
103 * Handle onKey() events coming down from a {@link com.five_ten_sg.connectbot.TerminalView} above us. |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
104 * Modify the keys to make more sense to a host then pass it to the 5250. |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
105 */ |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
106 public boolean onKey(View v, int keyCode, KeyEvent event) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
107 try { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
108 // skip keys if we aren't connected yet or have been disconnected |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
109 if (bridge.isDisconnected() || bridge.transport == null) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
110 return false; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
111 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
112 final boolean hardKeyboardHidden = manager.hardKeyboardHidden; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
113 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
114 // Ignore all key-up events except for the special keys |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
115 if (event.getAction() == KeyEvent.ACTION_UP) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
116 // There's nothing here for virtual keyboard users. |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
117 if (!hardKeyboard || (hardKeyboard && hardKeyboardHidden)) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
118 return false; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
119 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
120 // if keycode debugging enabled, log and print the pressed key |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
121 if (prefs.getBoolean(PreferenceConstants.DEBUG_KEYCODES, false)) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
122 String keyCodeString = String.format(": %d", keyCode); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
123 String toastText = v.getContext().getString(R.string.keycode_pressed) + keyCodeString; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
124 Log.d(TAG, toastText); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
125 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
126 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
127 if (fullKeyboard()) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
128 switch (keyCode) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
129 case KeyEvent.KEYCODE_CTRL_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
130 case KeyEvent.KEYCODE_CTRL_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
131 metaKeyUp(META_CTRL_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
132 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
133 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
134 case KeyEvent.KEYCODE_ALT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
135 case KeyEvent.KEYCODE_ALT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
136 metaKeyUp(META_ALT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
137 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
138 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
139 case KeyEvent.KEYCODE_SHIFT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
140 case KeyEvent.KEYCODE_SHIFT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
141 metaKeyUp(META_SHIFT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
142 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
143 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
144 default: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
145 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
146 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
147 else if (PreferenceConstants.KEYMODE_RIGHT.equals(keymode)) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
148 if (keyCode == KeyEvent.KEYCODE_ALT_RIGHT |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
149 && (metaState & META_SLASH) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
150 metaState &= ~(META_SLASH | META_TRANSIENT); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
151 buffer.write('/'); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
152 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
153 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
154 else if (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
155 && (metaState & META_TAB) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
156 metaState &= ~(META_TAB | META_TRANSIENT); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
157 buffer.write("[tab]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
158 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
159 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
160 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
161 else if (PreferenceConstants.KEYMODE_LEFT.equals(keymode)) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
162 if (keyCode == KeyEvent.KEYCODE_ALT_LEFT |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
163 && (metaState & META_SLASH) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
164 metaState &= ~(META_SLASH | META_TRANSIENT); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
165 buffer.write('/'); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
166 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
167 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
168 else if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
169 && (metaState & META_TAB) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
170 metaState &= ~(META_TAB | META_TRANSIENT); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
171 buffer.write("[tab]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
172 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
173 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
174 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
175 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
176 return false; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
177 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
178 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
179 bridge.resetScrollPosition(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
180 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
181 if (keyCode == KeyEvent.KEYCODE_UNKNOWN && |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
182 event.getAction() == KeyEvent.ACTION_MULTIPLE) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
183 byte[] input = event.getCharacters().getBytes(encoding); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
184 buffer.write(input); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
185 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
186 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
187 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
188 int curMetaState = event.getMetaState(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
189 final int orgMetaState = curMetaState; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
190 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
191 if ((metaState & META_SHIFT_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
192 curMetaState |= KeyEvent.META_SHIFT_ON; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
193 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
194 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
195 if ((metaState & META_ALT_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
196 curMetaState |= KeyEvent.META_ALT_ON; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
197 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
198 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
199 int uchar = event.getUnicodeChar(curMetaState); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
200 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
201 // no hard keyboard? ALT-k should pass through to below |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
202 if ((orgMetaState & KeyEvent.META_ALT_ON) != 0 && |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
203 (!hardKeyboard || hardKeyboardHidden)) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
204 uchar = 0; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
205 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
206 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
207 if ((uchar & KeyCharacterMap.COMBINING_ACCENT) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
208 mDeadKey = uchar & KeyCharacterMap.COMBINING_ACCENT_MASK; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
209 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
210 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
211 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
212 if (mDeadKey != 0 && uchar != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
213 uchar = KeyCharacterMap.getDeadChar(mDeadKey, uchar); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
214 mDeadKey = 0; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
215 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
216 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
217 // handle customized keymaps |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
218 if (customKeymapAction(v, keyCode, event)) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
219 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
220 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
221 if (v != null) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
222 //Show up the CharacterPickerDialog when the SYM key is pressed |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
223 if ((isSymKey(keyCode) || uchar == KeyCharacterMap.PICKER_DIALOG_INPUT)) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
224 bridge.showCharPickerDialog(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
225 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
226 if (metaState == 4) { // reset fn-key state |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
227 metaState = 0; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
228 bridge.redraw(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
229 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
230 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
231 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
232 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
233 else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
234 //Show up the URL scan dialog when the search key is pressed |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
235 urlScan(v); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
236 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
237 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
238 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
239 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
240 // otherwise pass through to existing session |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
241 // print normal keys |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
242 if (uchar > 0x00 && keyCode != KeyEvent.KEYCODE_ENTER) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
243 metaState &= ~(META_SLASH | META_TAB); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
244 // Remove shift and alt modifiers |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
245 final int lastMetaState = metaState; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
246 metaState &= ~(META_SHIFT_ON | META_ALT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
247 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
248 if (metaState != lastMetaState) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
249 bridge.redraw(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
250 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
251 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
252 if ((metaState & META_CTRL_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
253 metaState &= ~META_CTRL_ON; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
254 bridge.redraw(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
255 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
256 // If there is no hard keyboard or there is a hard keyboard currently hidden, |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
257 // CTRL-1 through CTRL-9 will send F1 through F9 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
258 if ((!hardKeyboard || (hardKeyboard && hardKeyboardHidden)) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
259 && sendFunctionKey(keyCode)) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
260 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
261 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
262 uchar = keyAsControl(uchar); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
263 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
264 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
265 // handle pressing f-keys |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
266 if ((hardKeyboard && !hardKeyboardHidden) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
267 && (curMetaState & KeyEvent.META_ALT_ON) != 0 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
268 && (curMetaState & KeyEvent.META_SHIFT_ON) != 0 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
269 && sendFunctionKey(keyCode)) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
270 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
271 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
272 if (uchar < 0x80) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
273 buffer.write(uchar); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
274 else |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
275 buffer.write(new String(Character.toChars(uchar)).getBytes(encoding)); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
276 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
277 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
278 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
279 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
280 // send ctrl and meta-keys as appropriate |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
281 if (!hardKeyboard || hardKeyboardHidden) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
282 int k = event.getUnicodeChar(0); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
283 int k0 = k; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
284 boolean sendCtrl = false; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
285 boolean sendMeta = false; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
286 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
287 if (k != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
288 if ((orgMetaState & HC_META_CTRL_ON) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
289 k = keyAsControl(k); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
290 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
291 if (k != k0) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
292 sendCtrl = true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
293 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
294 // send F1-F10 via CTRL-1 through CTRL-0 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
295 if (!sendCtrl && sendFunctionKey(keyCode)) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
296 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
297 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
298 else if ((orgMetaState & KeyEvent.META_ALT_ON) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
299 sendMeta = true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
300 buffer.write(0x1b); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
301 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
302 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
303 if (sendMeta || sendCtrl) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
304 buffer.write(k); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
305 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
306 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
307 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
308 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
309 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
310 // handle meta and f-keys for full hardware keyboard |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
311 if (hardKeyboard && !hardKeyboardHidden && fullKeyboard()) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
312 int k = event.getUnicodeChar(orgMetaState & KeyEvent.META_SHIFT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
313 int k0 = k; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
314 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
315 if (k != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
316 if ((orgMetaState & HC_META_CTRL_ON) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
317 k = keyAsControl(k); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
318 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
319 if (k != k0) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
320 buffer.write(k); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
321 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
322 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
323 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
324 else if ((orgMetaState & KeyEvent.META_ALT_ON) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
325 buffer.write(0x1b); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
326 buffer.write(k); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
327 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
328 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
329 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
330 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
331 if (sendFullSpecialKey(keyCode)) |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
332 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
333 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
334 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
335 // try handling keymode shortcuts |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
336 if (hardKeyboard && !hardKeyboardHidden && |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
337 event.getRepeatCount() == 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
338 if (PreferenceConstants.KEYMODE_RIGHT.equals(keymode)) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
339 switch (keyCode) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
340 case KeyEvent.KEYCODE_ALT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
341 metaState |= META_SLASH; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
342 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
343 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
344 case KeyEvent.KEYCODE_SHIFT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
345 metaState |= META_TAB; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
346 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
347 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
348 case KeyEvent.KEYCODE_SHIFT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
349 metaPress(META_SHIFT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
350 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
351 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
352 case KeyEvent.KEYCODE_ALT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
353 metaPress(META_ALT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
354 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
355 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
356 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
357 else if (PreferenceConstants.KEYMODE_LEFT.equals(keymode)) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
358 switch (keyCode) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
359 case KeyEvent.KEYCODE_ALT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
360 metaState |= META_SLASH; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
361 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
362 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
363 case KeyEvent.KEYCODE_SHIFT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
364 metaState |= META_TAB; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
365 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
366 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
367 case KeyEvent.KEYCODE_SHIFT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
368 metaPress(META_SHIFT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
369 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
370 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
371 case KeyEvent.KEYCODE_ALT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
372 metaPress(META_ALT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
373 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
374 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
375 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
376 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
377 switch (keyCode) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
378 case KeyEvent.KEYCODE_ALT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
379 case KeyEvent.KEYCODE_ALT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
380 metaPress(META_ALT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
381 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
382 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
383 case KeyEvent.KEYCODE_SHIFT_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
384 case KeyEvent.KEYCODE_SHIFT_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
385 metaPress(META_SHIFT_ON); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
386 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
387 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
388 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
389 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
390 // Handle hardware CTRL keys |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
391 if (keyCode == KeyEvent.KEYCODE_CTRL_LEFT || |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
392 keyCode == KeyEvent.KEYCODE_CTRL_RIGHT) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
393 ctrlKeySpecial(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
394 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
395 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
396 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
397 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
398 // look for special chars |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
399 switch (keyCode) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
400 case KEYCODE_ESCAPE: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
401 buffer.write(0x1b); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
402 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
403 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
404 case KeyEvent.KEYCODE_TAB: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
405 buffer.write("[tab]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
406 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
407 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
408 case KEYCODE_PAGE_DOWN: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
409 buffer.write("[pgdown]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
410 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
411 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
412 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
413 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
414 case KEYCODE_PAGE_UP: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
415 buffer.write("[pgup]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
416 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
417 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
418 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
419 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
420 case KeyEvent.KEYCODE_MOVE_HOME: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
421 buffer.write("[home]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
422 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
423 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
424 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
425 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
426 case KeyEvent.KEYCODE_MOVE_END: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
427 buffer.write("[end]"); // does not exist!! |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
428 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
429 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
430 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
431 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
432 case KeyEvent.KEYCODE_CAMERA: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
433 // check to see which shortcut the camera button triggers |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
434 String hwbuttonShortcut = manager.prefs.getString( |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
435 PreferenceConstants.CAMERA, |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
436 PreferenceConstants.HWBUTTON_SCREEN_CAPTURE); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
437 return (handleShortcut(v, hwbuttonShortcut)); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
438 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
439 case KeyEvent.KEYCODE_VOLUME_UP: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
440 // check to see which shortcut the volume button triggers |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
441 hwbuttonShortcut = manager.prefs.getString( |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
442 PreferenceConstants.VOLUP, |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
443 PreferenceConstants.HWBUTTON_CTRL); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
444 return (handleShortcut(v, hwbuttonShortcut)); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
445 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
446 case KeyEvent.KEYCODE_VOLUME_DOWN: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
447 // check to see which shortcut the camera button triggers |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
448 hwbuttonShortcut = manager.prefs.getString( |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
449 PreferenceConstants.VOLDN, |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
450 PreferenceConstants.HWBUTTON_TAB); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
451 return (handleShortcut(v, hwbuttonShortcut)); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
452 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
453 case KeyEvent.KEYCODE_SEARCH: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
454 // check to see which shortcut the search button triggers |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
455 hwbuttonShortcut = manager.prefs.getString( |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
456 PreferenceConstants.SEARCH, |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
457 PreferenceConstants.HWBUTTON_ESC); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
458 return (handleShortcut(v, hwbuttonShortcut)); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
459 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
460 case KeyEvent.KEYCODE_DEL: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
461 if ((metaState & META_ALT_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
462 buffer.write("[insert]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
463 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
464 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
465 buffer.write("[backspace]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
466 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
467 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
468 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
469 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
470 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
471 case KeyEvent.KEYCODE_ENTER: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
472 buffer.write("[enter]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
473 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
474 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
475 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
476 case KeyEvent.KEYCODE_DPAD_LEFT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
477 if (selectingForCopy) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
478 selectionArea.decrementColumn(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
479 bridge.redraw(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
480 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
481 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
482 if ((metaState & META_ALT_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
483 buffer.write("[home]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
484 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
485 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
486 buffer.write("[left]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
487 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
488 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
489 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
490 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
491 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
492 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
493 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
494 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
495 case KeyEvent.KEYCODE_DPAD_UP: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
496 if (selectingForCopy) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
497 selectionArea.decrementRow(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
498 bridge.redraw(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
499 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
500 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
501 if ((metaState & META_ALT_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
502 buffer.write("[pgup]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
503 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
504 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
505 buffer.write("[up]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
506 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
507 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
508 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
509 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
510 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
511 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
512 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
513 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
514 case KeyEvent.KEYCODE_DPAD_DOWN: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
515 if (selectingForCopy) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
516 selectionArea.incrementRow(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
517 bridge.redraw(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
518 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
519 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
520 if ((metaState & META_ALT_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
521 buffer.write("[pgdown]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
522 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
523 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
524 buffer.write("[down]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
525 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
526 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
527 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
528 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
529 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
530 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
531 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
532 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
533 case KeyEvent.KEYCODE_DPAD_RIGHT: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
534 if (selectingForCopy) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
535 selectionArea.incrementColumn(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
536 bridge.redraw(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
537 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
538 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
539 if ((metaState & META_ALT_MASK) != 0) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
540 buffer.write("[end]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
541 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
542 else { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
543 buffer.write("[right]"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
544 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
545 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
546 metaState &= ~META_TRANSIENT; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
547 bridge.tryKeyVibrate(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
548 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
549 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
550 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
551 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
552 case KeyEvent.KEYCODE_DPAD_CENTER: |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
553 ctrlKeySpecial(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
554 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
555 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
556 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
557 catch (IOException e) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
558 Log.e(TAG, "Problem while trying to handle an onKey() event", e); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
559 |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
560 try { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
561 bridge.transport.flush(); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
562 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
563 catch (IOException ioe) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
564 Log.d(TAG, "Our transport was closed, dispatching disconnect event"); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
565 bridge.dispatchDisconnect(false); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
566 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
567 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
568 catch (NullPointerException npe) { |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
569 Log.d(TAG, "Input before connection established ignored."); |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
570 return true; |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
571 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
572 } |
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
573 |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
574 }; |
12 | 575 |
49
8887bff45dee
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
47
diff
changeset
|
576 |
11 | 577 public TN5250() { |
578 super(); | |
579 } | |
580 | |
581 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
582 /** |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
583 * @return protocol part of the URI |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
584 */ |
11 | 585 public static String getProtocolName() { |
586 return PROTOCOL; | |
587 } | |
588 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
589 |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
590 /** |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
591 * 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
|
592 * @return URI to host |
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
593 */ |
12 | 594 public Uri getUri(String input) { |
595 Matcher matcher = hostmask.matcher(input); | |
596 | |
597 if (!matcher.matches()) | |
598 return null; | |
599 | |
600 StringBuilder sb = new StringBuilder(); | |
601 sb.append(PROTOCOL) | |
602 .append("://") | |
603 .append(matcher.group(1)); | |
604 String portString = matcher.group(3); | |
605 int port = DEFAULT_PORT; | |
606 | |
607 if (portString != null) { | |
608 try { | |
609 port = Integer.parseInt(portString); | |
610 | |
611 if (port < 1 || port > 65535) { | |
612 port = DEFAULT_PORT; | |
613 } | |
614 } | |
615 catch (NumberFormatException nfe) { | |
616 // Keep the default port | |
617 } | |
618 } | |
619 | |
620 if (port != DEFAULT_PORT) { | |
621 sb.append(':'); | |
622 sb.append(port); | |
623 } | |
624 | |
625 sb.append("/#") | |
626 .append(Uri.encode(input)); | |
627 Uri uri = Uri.parse(sb.toString()); | |
628 return uri; | |
11 | 629 } |
630 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
631 |
11 | 632 /** |
633 * Causes transport to connect to the target host. After connecting but before a | |
634 * session is started, must call back to {@link TerminalBridge#onConnected()}. | |
635 * After that call a session may be opened. | |
636 */ | |
637 @Override | |
638 public void connect() { | |
30
d738f6b876fe
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
29
diff
changeset
|
639 screen52 = new Screen5250(); |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
640 handler = new tnvt(screen52, true, false, bridge, manager); |
37
0395ca628303
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
32
diff
changeset
|
641 handler.setSSLType("TLS"); |
32
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
642 screen52.setVT(handler); |
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
643 screen52.setBuffer(buffer); |
23 | 644 connected = handler.connect(host.getHostname(), host.getPort()); |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
645 if (connected) bridge.onConnected(); |
11 | 646 } |
647 | |
648 | |
649 /** | |
650 * Checks if read() will block. If there are no bytes remaining in | |
651 * the underlying transport, return true. | |
652 */ | |
653 @Override | |
654 public boolean willBlock() { | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
655 // 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
|
656 return true; |
11 | 657 } |
658 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
659 |
11 | 660 /** |
661 * Reads from the transport. Transport must support reading into a byte array | |
662 * <code>buffer</code> at the start of <code>offset</code> and a maximum of | |
663 * <code>length</code> bytes. If the remote host disconnects, throw an | |
664 * {@link IOException}. | |
665 * @param buffer byte buffer to store read bytes into | |
666 * @param offset where to start writing in the buffer | |
667 * @param length maximum number of bytes to read | |
668 * @return number of bytes read | |
669 * @throws IOException when remote host disconnects | |
670 */ | |
671 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
|
672 // we don't use a relay thread between the transport and the vt320 buffer |
11 | 673 return 0; |
674 } | |
675 | |
676 | |
677 /** | |
678 * Writes to the transport. If the host is not yet connected, simply return without | |
679 * doing anything. An {@link IOException} should be thrown if there is an error after | |
680 * connection. | |
681 * @param buffer bytes to write to transport | |
682 * @throws IOException when there is a problem writing after connection | |
683 */ | |
684 public void write(byte[] buffer) throws IOException { | |
685 } | |
686 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
687 |
11 | 688 /** |
689 * Writes to the transport. See {@link #write(byte[])} for behavior details. | |
690 * @param c character to write to the transport | |
691 * @throws IOException when there is a problem writing after connection | |
692 */ | |
693 public void write(int c) throws IOException { | |
694 } | |
695 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
696 |
11 | 697 /** |
698 * Flushes the write commands to the transport. | |
699 * @throws IOException when there is a problem writing after connection | |
700 */ | |
701 public void flush() throws IOException { | |
702 } | |
703 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
704 |
11 | 705 /** |
32
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
706 * Closes the connection to the terminal. |
11 | 707 */ |
708 public void close() { | |
13 | 709 handler.disconnect(); |
11 | 710 connected = false; |
32
b086dd794dba
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
31
diff
changeset
|
711 bridge.dispatchDisconnect(false); |
11 | 712 } |
713 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
714 |
11 | 715 /** |
716 * Tells the transport what dimensions the display is currently | |
717 * @param columns columns of text | |
718 * @param rows rows of text | |
719 * @param width width in pixels | |
720 * @param height height in pixels | |
721 */ | |
722 @Override | |
723 public void setDimensions(int columns, int rows, int width, int height) { | |
724 // do nothing | |
725 } | |
726 | |
727 | |
728 @Override | |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
729 public vt320 getTransportBuffer() { |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
730 buffer = new vt320x5250(); |
47
a3fd10a8c0de
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
46
diff
changeset
|
731 return setupTransportBuffer(); |
45
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
732 } |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
733 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
734 |
80dcebe51af2
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
43
diff
changeset
|
735 @Override |
11 | 736 public int getDefaultPort() { |
737 return DEFAULT_PORT; | |
738 } | |
739 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
740 |
11 | 741 @Override |
742 public boolean isConnected() { | |
743 return connected; | |
744 } | |
745 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
746 |
11 | 747 @Override |
748 public boolean isSessionOpen() { | |
749 return connected; | |
750 } | |
751 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
752 |
11 | 753 @Override |
754 public boolean isAuthenticated() { | |
755 return connected; | |
756 } | |
757 | |
758 | |
759 @Override | |
760 public String getDefaultNickname(String username, String hostname, int port) { | |
761 if (port == DEFAULT_PORT) { | |
762 return String.format("%s", hostname); | |
763 } | |
764 else { | |
765 return String.format("%s:%d", hostname, port); | |
766 } | |
767 } | |
768 | |
31
139394237973
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
30
diff
changeset
|
769 |
11 | 770 @Override |
771 public void getSelectionArgs(Uri uri, Map<String, String> selection) { | |
772 selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL); | |
773 selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment()); | |
774 selection.put(HostDatabase.FIELD_HOST_HOSTNAME, uri.getHost()); | |
775 int port = uri.getPort(); | |
776 | |
777 if (port < 0) | |
778 port = DEFAULT_PORT; | |
779 | |
780 selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port)); | |
781 } | |
782 | |
783 | |
784 @Override | |
785 public HostBean createHost(Uri uri) { | |
786 HostBean host = new HostBean(); | |
787 host.setProtocol(PROTOCOL); | |
788 host.setHostname(uri.getHost()); | |
789 int port = uri.getPort(); | |
790 | |
791 if (port < 0) | |
792 port = DEFAULT_PORT; | |
793 | |
794 host.setPort(port); | |
795 String nickname = uri.getFragment(); | |
796 | |
797 if (nickname == null || nickname.length() == 0) { | |
798 host.setNickname(getDefaultNickname(host.getUsername(), | |
799 host.getHostname(), host.getPort())); | |
800 } | |
801 else { | |
802 host.setNickname(uri.getFragment()); | |
803 } | |
804 | |
805 return host; | |
806 } | |
807 | |
808 | |
12 | 809 public String getFormatHint(Context context) { |
11 | 810 return String.format("%s:%s", |
811 context.getString(R.string.format_hostname), | |
812 context.getString(R.string.format_port)); | |
813 } | |
814 | |
815 | |
816 @Override | |
817 public boolean usesNetwork() { | |
818 return true; | |
819 } | |
29
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
820 |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
821 |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
822 @Override |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
823 public boolean needsRelay() { |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
824 // 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
|
825 return false; |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
826 } |
017eeed8332c
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
23
diff
changeset
|
827 |
43
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
828 public TerminalKeyListener getTerminalKeyListener() { |
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
829 return new Terminal5250KeyListener(manager, bridge, buffer, host.getEncoding()); |
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
830 } |
6b0f1ece1d91
start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents:
37
diff
changeset
|
831 |
11 | 832 } |