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