annotate src/com/five_ten_sg/connectbot/transport/TN5250.java @ 50:2cd3d8091e37 tn5250

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