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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /*
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 * 510ConnectBot
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 * Copyright 2014 Carl Byington
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 * Licensed under the Apache License, Version 2.0 (the "License");
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 * you may not use this file except in compliance with the License.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 * You may obtain a copy of the License at
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 * http://www.apache.org/licenses/LICENSE-2.0
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 * Unless required by applicable law or agreed to in writing, software
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 * distributed under the License is distributed on an "AS IS" BASIS,
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 * See the License for the specific language governing permissions and
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 * limitations under the License.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 package com.five_ten_sg.connectbot.transport;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 import java.io.IOException;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 import java.io.InputStream;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 import java.io.OutputStream;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 import java.net.Socket;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 import java.net.SocketException;
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
25 import java.net.UnknownHostException;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 import java.util.List;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 import java.util.Map;
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
28 import java.util.regex.Matcher;
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
29 import java.util.regex.Pattern;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30
12
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
31 import org.tn5250j.framework.tn5250.Screen5250;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
32 import org.tn5250j.framework.tn5250.tnvt;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
33
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
34 import com.five_ten_sg.connectbot.R;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 import com.five_ten_sg.connectbot.bean.HostBean;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 import com.five_ten_sg.connectbot.bean.PortForwardBean;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 import com.five_ten_sg.connectbot.service.TerminalManager;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40 import com.five_ten_sg.connectbot.util.HostDatabase;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 import android.content.Context;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42 import android.net.Uri;
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 * @author Carl Byington
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 public class TN5250 extends AbsTransport {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
52 private static final String PROTOCOL = "tn5250";
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
53 private static final String TAG = "ConnectBot.tn5250";
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60
12
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
61 static final Pattern hostmask;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
62 static {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
63 hostmask = Pattern.compile("^([0-9a-z.-]+)(:(\\d+))?$", Pattern.CASE_INSENSITIVE);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
64 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
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
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
575
49
8887bff45dee start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 47
diff changeset
576
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
577 public TN5250() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
578 super();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
579 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
580
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
585 public static String getProtocolName() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
586 return PROTOCOL;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
587 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
594 public Uri getUri(String input) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
595 Matcher matcher = hostmask.matcher(input);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
596
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
597 if (!matcher.matches())
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
598 return null;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
599
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
600 StringBuilder sb = new StringBuilder();
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
601 sb.append(PROTOCOL)
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
602 .append("://")
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
603 .append(matcher.group(1));
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
604 String portString = matcher.group(3);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
605 int port = DEFAULT_PORT;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
606
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
607 if (portString != null) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
608 try {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
609 port = Integer.parseInt(portString);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
610
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
611 if (port < 1 || port > 65535) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
612 port = DEFAULT_PORT;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
613 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
614 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
615 catch (NumberFormatException nfe) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
616 // Keep the default port
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
617 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
618 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
619
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
620 if (port != DEFAULT_PORT) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
621 sb.append(':');
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
622 sb.append(port);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
623 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
624
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
625 sb.append("/#")
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
626 .append(Uri.encode(input));
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
627 Uri uri = Uri.parse(sb.toString());
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
628 return uri;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
629 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
630
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
631
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
632 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
633 * Causes transport to connect to the target host. After connecting but before a
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
634 * session is started, must call back to {@link TerminalBridge#onConnected()}.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
635 * After that call a session may be opened.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
636 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
637 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
cfcb8d9859a8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 13
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
646 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
647
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
648
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
649 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
650 * Checks if read() will block. If there are no bytes remaining in
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
651 * the underlying transport, return true.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
652 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
653 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
657 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
658
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
659
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
660 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
661 * Reads from the transport. Transport must support reading into a byte array
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
662 * <code>buffer</code> at the start of <code>offset</code> and a maximum of
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
663 * <code>length</code> bytes. If the remote host disconnects, throw an
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
664 * {@link IOException}.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
665 * @param buffer byte buffer to store read bytes into
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
666 * @param offset where to start writing in the buffer
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
667 * @param length maximum number of bytes to read
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
668 * @return number of bytes read
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
669 * @throws IOException when remote host disconnects
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
670 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
673 return 0;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
674 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
675
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
676
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
677 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
678 * Writes to the transport. If the host is not yet connected, simply return without
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
679 * doing anything. An {@link IOException} should be thrown if there is an error after
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
680 * connection.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
681 * @param buffer bytes to write to transport
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
682 * @throws IOException when there is a problem writing after connection
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
683 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
684 public void write(byte[] buffer) throws IOException {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
685 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
686
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
687
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
688 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
689 * Writes to the transport. See {@link #write(byte[])} for behavior details.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
690 * @param c character to write to the transport
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
691 * @throws IOException when there is a problem writing after connection
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
692 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
693 public void write(int c) throws IOException {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
694 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
695
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
696
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
697 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
698 * Flushes the write commands to the transport.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
699 * @throws IOException when there is a problem writing after connection
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
700 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
701 public void flush() throws IOException {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
702 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
703
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
704
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
707 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
708 public void close() {
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
709 handler.disconnect();
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
710 connected = false;
32
b086dd794dba start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 31
diff changeset
711 bridge.dispatchDisconnect(false);
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
712 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
713
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
714
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
715 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
716 * Tells the transport what dimensions the display is currently
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
717 * @param columns columns of text
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
718 * @param rows rows of text
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
719 * @param width width in pixels
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
720 * @param height height in pixels
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
721 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
722 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
723 public void setDimensions(int columns, int rows, int width, int height) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
724 // do nothing
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
725 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
726
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
727
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
736 public int getDefaultPort() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
737 return DEFAULT_PORT;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
738 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
739
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
740
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
741 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
742 public boolean isConnected() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
743 return connected;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
744 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
745
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
746
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
747 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
748 public boolean isSessionOpen() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
749 return connected;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
750 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
751
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
752
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
753 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
754 public boolean isAuthenticated() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
755 return connected;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
756 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
757
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
758
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
759 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
760 public String getDefaultNickname(String username, String hostname, int port) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
761 if (port == DEFAULT_PORT) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
762 return String.format("%s", hostname);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
763 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
764 else {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
765 return String.format("%s:%d", hostname, port);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
766 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
767 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
768
31
139394237973 start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 30
diff changeset
769
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
770 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
771 public void getSelectionArgs(Uri uri, Map<String, String> selection) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
772 selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
773 selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
774 selection.put(HostDatabase.FIELD_HOST_HOSTNAME, uri.getHost());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
775 int port = uri.getPort();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
776
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
777 if (port < 0)
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
778 port = DEFAULT_PORT;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
779
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
780 selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port));
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
781 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
782
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
783
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
784 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
785 public HostBean createHost(Uri uri) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
786 HostBean host = new HostBean();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
787 host.setProtocol(PROTOCOL);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
788 host.setHostname(uri.getHost());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
789 int port = uri.getPort();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
790
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
791 if (port < 0)
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
792 port = DEFAULT_PORT;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
793
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
794 host.setPort(port);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
795 String nickname = uri.getFragment();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
796
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
797 if (nickname == null || nickname.length() == 0) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
798 host.setNickname(getDefaultNickname(host.getUsername(),
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
799 host.getHostname(), host.getPort()));
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
800 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
801 else {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
802 host.setNickname(uri.getFragment());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
803 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
804
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
805 return host;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
806 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
807
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
808
12
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
809 public String getFormatHint(Context context) {
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
810 return String.format("%s:%s",
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
811 context.getString(R.string.format_hostname),
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
812 context.getString(R.string.format_port));
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
813 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
814
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
815
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
816 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
817 public boolean usesNetwork() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
818 return true;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
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
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
832 }