annotate app/src/main/java/org/tn5250j/framework/tn5250/tnvt.java @ 470:2cc170e3fc9b stable-1.9.3-8

audible bell checkbox enables/disables bell volume setting; monitor init string is now a url socket://target/initstring
author Carl Byington <carl@five-ten-sg.com>
date Fri, 04 Oct 2019 16:44:44 -0700
parents 5ce5235adde6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /**
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 * Title: tnvt.java
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 * Copyright: Copyright (c) 2001 Company:
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 * @author Kenneth J. Pouncey
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 * @version 0.5
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 * Description:
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify it under
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 * the terms of the GNU General Public License as published by the Free Software
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 * Foundation; either version 2, or (at your option) any later version.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but WITHOUT
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 * details.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License along with
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 * this software; see the file COPYING. If not, write to the Free Software
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 */
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 package org.tn5250j.framework.tn5250;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25
348
29076621bab0 merge tn5250j r1227; fix spelling
Carl Byington <carl@five-ten-sg.com>
parents: 307
diff changeset
26 import static java.lang.Math.max;
29076621bab0 merge tn5250j r1227; fix spelling
Carl Byington <carl@five-ten-sg.com>
parents: 307
diff changeset
27 import static java.lang.Math.min;
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 import static org.tn5250j.TN5250jConstants.AID_HELP;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 import static org.tn5250j.TN5250jConstants.AID_PRINT;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 import static org.tn5250j.TN5250jConstants.CMD_CLEAR_FORMAT_TABLE;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 import static org.tn5250j.TN5250jConstants.CMD_CLEAR_UNIT;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 import static org.tn5250j.TN5250jConstants.CMD_CLEAR_UNIT_ALTERNATE;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 import static org.tn5250j.TN5250jConstants.CMD_READ_INPUT_FIELDS;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34 import static org.tn5250j.TN5250jConstants.CMD_READ_MDT_FIELDS;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 import static org.tn5250j.TN5250jConstants.CMD_READ_MDT_IMMEDIATE_ALT;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 import static org.tn5250j.TN5250jConstants.CMD_READ_SCREEN_IMMEDIATE;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 import static org.tn5250j.TN5250jConstants.CMD_READ_SCREEN_TO_PRINT;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 import static org.tn5250j.TN5250jConstants.CMD_RESTORE_SCREEN;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 import static org.tn5250j.TN5250jConstants.CMD_ROLL;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40 import static org.tn5250j.TN5250jConstants.CMD_SAVE_SCREEN;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 import static org.tn5250j.TN5250jConstants.CMD_WRITE_ERROR_CODE;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42 import static org.tn5250j.TN5250jConstants.CMD_WRITE_ERROR_CODE_TO_WINDOW;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
43 import static org.tn5250j.TN5250jConstants.CMD_WRITE_STRUCTURED_FIELD;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44 import static org.tn5250j.TN5250jConstants.CMD_WRITE_TO_DISPLAY;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45 import static org.tn5250j.TN5250jConstants.NR_REQUEST_ERROR;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 import static org.tn5250j.TN5250jConstants.PF1;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 import static org.tn5250j.TN5250jConstants.PF10;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 import static org.tn5250j.TN5250jConstants.PF11;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49 import static org.tn5250j.TN5250jConstants.PF12;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 import static org.tn5250j.TN5250jConstants.PF13;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 import static org.tn5250j.TN5250jConstants.PF14;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
52 import static org.tn5250j.TN5250jConstants.PF15;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
53 import static org.tn5250j.TN5250jConstants.PF16;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
54 import static org.tn5250j.TN5250jConstants.PF17;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
55 import static org.tn5250j.TN5250jConstants.PF18;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
56 import static org.tn5250j.TN5250jConstants.PF19;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
57 import static org.tn5250j.TN5250jConstants.PF2;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
58 import static org.tn5250j.TN5250jConstants.PF20;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59 import static org.tn5250j.TN5250jConstants.PF21;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60 import static org.tn5250j.TN5250jConstants.PF22;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
61 import static org.tn5250j.TN5250jConstants.PF23;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 import static org.tn5250j.TN5250jConstants.PF24;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63 import static org.tn5250j.TN5250jConstants.PF3;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64 import static org.tn5250j.TN5250jConstants.PF4;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65 import static org.tn5250j.TN5250jConstants.PF5;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
66 import static org.tn5250j.TN5250jConstants.PF6;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
67 import static org.tn5250j.TN5250jConstants.PF7;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
68 import static org.tn5250j.TN5250jConstants.PF8;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
69 import static org.tn5250j.TN5250jConstants.PF9;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
70
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71 import java.io.BufferedInputStream;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72 import java.io.BufferedOutputStream;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73 import java.io.ByteArrayOutputStream;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74 import java.io.IOException;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75 import java.io.InputStream;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76 import java.io.OutputStream;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77 import java.net.Socket;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 import java.util.Arrays;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
79 import java.util.Properties;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
80 import java.util.concurrent.ArrayBlockingQueue;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
81 import java.util.concurrent.BlockingQueue;
99
eda03b809f48 move blocking test from socket read to queue take
Carl Byington <carl@five-ten-sg.com>
parents: 91
diff changeset
82 import java.util.concurrent.TimeUnit;
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 import javax.net.ssl.SSLSocket;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84
71
7ae9b0c382ec use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents: 69
diff changeset
85 import android.content.Intent;
7ae9b0c382ec use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents: 69
diff changeset
86 import android.net.Uri;
7ae9b0c382ec use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents: 69
diff changeset
87 import android.util.Log;
7ae9b0c382ec use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents: 69
diff changeset
88
24
d1c549560aff adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 23
diff changeset
89 import com.five_ten_sg.connectbot.R;
119
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
90 import com.five_ten_sg.connectbot.bean.HostBean;
8
3b760b39962a adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 6
diff changeset
91 import com.five_ten_sg.connectbot.service.TerminalBridge;
3b760b39962a adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 6
diff changeset
92 import com.five_ten_sg.connectbot.service.TerminalManager;
71
7ae9b0c382ec use 5250 encryption config entry
Carl Byington <carl@five-ten-sg.com>
parents: 69
diff changeset
93 import de.mud.terminal.vt320;
8
3b760b39962a adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 6
diff changeset
94
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
95 import org.tn5250j.TN5250jConstants;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
96 import org.tn5250j.encoding.CharMappings;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
97 import org.tn5250j.encoding.ICodePage;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
98 import org.tn5250j.framework.transport.SocketConnector;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
99
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
100
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
101 public final class tnvt implements Runnable {
26
9ae1c889a64c adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 25
diff changeset
102 private static final String TAG = "tnvt";
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
103 // negotiating commands
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
104 private static final byte IAC = (byte) - 1; // 255 FF
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
105 private static final byte DONT = (byte) - 2; //254 FE
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
106 private static final byte DO = (byte) - 3; //253 FD
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
107 private static final byte WONT = (byte) - 4; //252 FC
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
108 private static final byte WILL = (byte) - 5; //251 FB
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
109 private static final byte SB = (byte) - 6; //250 Sub Begin FA
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
110 private static final byte SE = (byte) - 16; //240 Sub End F0
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
111 private static final byte EOR = (byte) - 17; //239 End of Record EF
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
112 private static final byte TERMINAL_TYPE = (byte) 24; // 18
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
113 private static final byte OPT_END_OF_RECORD = (byte) 25; // 19
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
114 private static final byte TRANSMIT_BINARY = (byte) 0; // 0
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
115 private static final byte QUAL_IS = (byte) 0; // 0
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
116 private static final byte TIMING_MARK = (byte) 6; // 6
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
117 private static final byte NEW_ENVIRONMENT = (byte) 39; // 27
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
118 private static final byte IS = (byte) 0; // 0
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
119 private static final byte SEND = (byte) 1; // 1
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
120 private static final byte INFO = (byte) 2; // 2
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
121 private static final byte VAR = (byte) 0; // 0
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
122 private static final byte VALUE = (byte) 1; // 1
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
123 private static final byte NEGOTIATE_ESC = (byte) 2; // 2
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
124 private static final byte USERVAR = (byte) 3; // 3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
125
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
126 // miscellaneous
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
127 private static final byte ESC = 0x04; // 04
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
128
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
129 private Socket sock;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
130 public BufferedInputStream bin;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
131 public BufferedOutputStream bout;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
132 private final BlockingQueue<Object> dsq = new ArrayBlockingQueue<Object>(25);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
133 private Stream5250 bk;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
134 private DataStreamProducer producer;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
135 protected Screen5250 screen52;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
136 private boolean waitingForInput;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
137 private boolean invited;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
138 private boolean negotiated = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
139 private Thread me;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
140 private Thread pthread;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
141 private int readType;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
142 private boolean enhanced = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
143 private boolean cursorOn = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
144 private String hostname = "";
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
145 private int port = 23;
99
eda03b809f48 move blocking test from socket read to queue take
Carl Byington <carl@five-ten-sg.com>
parents: 91
diff changeset
146 private vt320 buffer;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
147 private boolean connected = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
148 private boolean support132 = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
149 private ByteArrayOutputStream baosp = null;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
150 private ByteArrayOutputStream baosrsp = null;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
151 private int devSeq = -1;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
152 private String devName;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
153 private String devNameUsed;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
154 private KbdTypesCodePages kbdTypesCodePage;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
155 // WVL - LDC : TR.000300 : Callback scenario from 5250
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
156 private boolean scan; // = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
157 private static int STRSCAN = 1;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
158 // WVL - LDC : 05/08/2005 : TFX.006253 - support STRPCCMD
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
159 private boolean strpccmd; // = false;
119
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
160 private String encryption;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
161 private String user;
125
6eab98e58bed add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 120
diff changeset
162 private String password = null;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
163 private String library;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
164 private String initialMenu;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
165 private String program;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
166 private boolean keepTrucking = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
167 private boolean pendingUnlock = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
168 private boolean[] dataIncluded;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
169 protected ICodePage codePage;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
170 private String sslType;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
171 private WTDSFParser sfParser;
8
3b760b39962a adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 6
diff changeset
172 private TerminalBridge bridge;
3b760b39962a adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 6
diff changeset
173 private TerminalManager manager;
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
174
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
175
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
176
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
177 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
178 * @param screen52
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
179 * @param enhanced
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
180 * @param support132
10
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
181 * @param bridge
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
182 * @param manager
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
183 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
184 public tnvt(Screen5250 screen52, boolean enhanced, boolean support132, TerminalBridge bridge, TerminalManager manager) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
185 this.screen52 = screen52;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
186 this.support132 = support132;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
187 this.enhanced = enhanced;
8
3b760b39962a adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 6
diff changeset
188 this.bridge = bridge;
3b760b39962a adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 6
diff changeset
189 this.manager = manager;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
190 setCodePage("37");
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
191 dataIncluded = new boolean[24];
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
192 baosp = new ByteArrayOutputStream();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
193 baosrsp = new ByteArrayOutputStream();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
194 }
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
195
10
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
196 public void showURL(String url) {
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
197 if (url.indexOf("://") < 0) url = "http://" + url;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
198
10
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
199 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
200 manager.startActivity(intent);
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
201 }
e773d0952613 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 8
diff changeset
202
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
203 public String getHostName() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
204 return hostname;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
205 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
206
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
207 public void setDeviceName(String name) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
208 devName = name;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
209 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
210
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
211 public String getDeviceName() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
212 return devName;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
213 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
214
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
215 public String getAllocatedDeviceName() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
216 return devNameUsed;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
217 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
218
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
219 public boolean isConnected() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
220 return connected;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
221 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
222
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
223 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
224 * @return true when SSL is used and socket is connected.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
225 * @see {@link #isConnected()}
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
226 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
227 public boolean isSslSocket() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
228 if (this.connected && this.sock != null && this.sock instanceof SSLSocket) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
229 return true;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
230 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
231 else {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
232 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
233 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
234 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
235
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
236 public final void setProxy(String proxyHost, String proxyPort) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
237 Properties systemProperties = System.getProperties();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
238 systemProperties.put("socksProxySet", "true");
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
239 systemProperties.put("socksProxyHost", proxyHost);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
240 systemProperties.put("socksProxyPort", proxyPort);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
241 System.setProperties(systemProperties);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
242 Log.i(TAG, " socks set ");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
243 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
244
120
dcac61b6f2e6 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 119
diff changeset
245 private String fixer(String value, String def) {
dcac61b6f2e6 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 119
diff changeset
246 if ((value == null) || (value.length() == 0)) return def;
307
071eccdff8ea fix java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 257
diff changeset
247
119
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
248 return value;
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
249 }
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
250
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
251 public final boolean connect(HostBean host, String homeDirectory, vt320 buffer) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
252 try {
119
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
253 this.hostname = host.getHostname();
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
254 this.port = host.getPort();
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
255 this.buffer = buffer;
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
256 this.encryption = fixer(host.getEncryption5250(), "NONE");
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
257 this.user = host.getUsername();
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
258 this.library = host.getLibrary();
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
259 this.initialMenu = host.getInitialMenu();
6969d6cebcd7 add more 5250 config items
Carl Byington <carl@five-ten-sg.com>
parents: 112
diff changeset
260 this.program = host.getProgram();
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
261
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
262 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
263 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
264 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, "X - Connecting");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
265 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
266 catch (Exception exc) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
267 Log.w(TAG, "setStatus(ON) " + exc.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
268 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
269
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
270 SocketConnector sc = new SocketConnector();
91
33eb63352be5 remove 5250 configuration
Carl Byington <carl@five-ten-sg.com>
parents: 71
diff changeset
271 sock = sc.createSocket(hostname, port, encryption, homeDirectory, bridge, manager);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
272
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
273 if (sock == null) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
274 Log.w(TAG, "I did not get a socket");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
275 disconnect();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
276 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
277 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
278
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
279 connected = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
280 // used for JDK1.3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
281 sock.setKeepAlive(true);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
282 sock.setTcpNoDelay(true);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
283 sock.setSoLinger(false, 0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
284 InputStream in = sock.getInputStream();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
285 OutputStream out = sock.getOutputStream();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
286 bin = new BufferedInputStream(in, 8192);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
287 bout = new BufferedOutputStream(out);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
288 byte abyte0[];
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
289
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
290 while (negotiate(abyte0 = readNegotiations()));
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
291
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
292 negotiated = true;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
293
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
294 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
295 screen52.setCursorActive(false);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
296 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
297 catch (Exception excc) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
298 Log.w(TAG, "setCursorOff " + excc.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
299 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
300
99
eda03b809f48 move blocking test from socket read to queue take
Carl Byington <carl@five-ten-sg.com>
parents: 91
diff changeset
301 producer = new DataStreamProducer(this, bin, dsq, abyte0);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
302 pthread = new Thread(producer);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
303 pthread.setPriority(Thread.NORM_PRIORITY);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
304 pthread.start();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
305
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
306 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
307 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
308 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
309 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
310 catch (Exception exc) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
311 Log.w(TAG, "setStatus(OFF) " + exc.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
312 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
313
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
314 keepTrucking = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
315 me = new Thread(this);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
316 me.start();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
317 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
318 catch (Exception exception) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
319 if (exception.getMessage() == null)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
320 exception.printStackTrace();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
321
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
322 Log.w(TAG, "connect() " + exception.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
323
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
324 if (sock == null)
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
325 Log.w(TAG, "I did not get a socket");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
326
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
327 disconnect();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
328 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
329 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
330
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
331 return true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
332 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
333
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
334 public final boolean disconnect() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
335 if (!connected) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
336 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
337 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, "X - Disconnected");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
338 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
339 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
340
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
341 if (me != null && me.isAlive()) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
342 me.interrupt();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
343 keepTrucking = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
344 pthread.interrupt();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
345 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
346
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
347 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
348 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, "X - Disconnected");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
349 screen52.getOIA().setKeyBoardLocked(false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
350 pendingUnlock = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
351
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
352 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
353 if (sock != null) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
354 Log.i(TAG, "Closing socket");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
355 sock.close();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
356 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
357
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
358 if (bin != null) bin.close();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
359
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
360 if (bout != null) bout.close();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
361
424
09c1d3aae3f0 updateDirty before testChanged, try to eliminate sending duplicate screenChanged to the monitor
Carl Byington <carl@five-ten-sg.com>
parents: 414
diff changeset
362 connected = false;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
363 // WVL - LDC : TR.000345 : properly disconnect and clear screen
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
364 // Is this the right place to set screen realestate on disconnect?
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
365 //controller.getScreen().clearAll();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
366 screen52.goto_XY(0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
367 screen52.setCursorActive(false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
368 screen52.clearAll();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
369 screen52.restoreScreen();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
370 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
371 catch (Exception exception) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
372 Log.w(TAG, exception.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
373 connected = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
374 devSeq = -1;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
375 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
376 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
377
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
378 devSeq = -1;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
379 return true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
380 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
381
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
382 private final ByteArrayOutputStream appendByteStream(byte abyte0[]) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
383 ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
384
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
385 for (int i = 0; i < abyte0.length; i++) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
386 bytearrayoutputstream.write(abyte0[i]);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
387
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
388 if (abyte0[i] == -1)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
389 bytearrayoutputstream.write(-1);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
390 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
391
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
392 return bytearrayoutputstream;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
393 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
394
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
395 private final byte[] readNegotiations() throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
396 int i = bin.read();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
397
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
398 if (i < 0) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
399 throw new IOException("Connection closed.");
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
400 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
401 else {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
402 int j = bin.available();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
403 byte abyte0[] = new byte[j + 1];
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
404 abyte0[0] = (byte) i;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
405 bin.read(abyte0, 1, j);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
406 return abyte0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
407 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
408 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
409
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
410 private final void writeByte(byte abyte0[]) throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
411 bout.write(abyte0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
412 bout.flush();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
413 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
414
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
415 private final void readImmediate(int readType) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
416 if (screen52.isStatusErrorCode()) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
417 screen52.restoreErrorLine();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
418 screen52.setStatus(Screen5250.STATUS_ERROR_CODE,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
419 Screen5250.STATUS_VALUE_OFF, null);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
420 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
421
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
422 if (!enhanced) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
423 screen52.setCursorActive(false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
424 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
425
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
426 // screen52.setStatus(Screen5250.STATUS_SYSTEM,
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
427 // Screen5250.STATUS_VALUE_ON, null);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
428 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
429 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
430 screen52.getOIA().setKeyBoardLocked(true);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
431 pendingUnlock = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
432 invited = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
433 screen52.getScreenFields().readFormatTable(baosp, readType, codePage);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
434
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
435 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
436 Log.i(TAG, "readImmediate() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
437 writeGDS(0, 3, baosp.toByteArray());
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
438 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
439 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
440 Log.w(TAG, ioe.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
441 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
442
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
443 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
444 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
445
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
446 public final boolean sendAidKey(int aid) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
447 if (screen52.isStatusErrorCode()) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
448 screen52.restoreErrorLine();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
449 screen52.setStatus(Screen5250.STATUS_ERROR_CODE,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
450 Screen5250.STATUS_VALUE_OFF, null);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
451 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
452
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
453 if (!enhanced) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
454 screen52.setCursorActive(false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
455 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
456
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
457 // screen52.setStatus(Screen5250.STATUS_SYSTEM,
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
458 // Screen5250.STATUS_VALUE_ON, null);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
459 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
460 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
461 screen52.getOIA().setKeyBoardLocked(true);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
462 pendingUnlock = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
463 invited = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
464 baosp.write(screen52.getCurrentRow());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
465 baosp.write(screen52.getCurrentCol());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
466 baosp.write(aid);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
467
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
468 if (dataIncluded(aid))
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
469 screen52.getScreenFields().readFormatTable(baosp, readType,
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
470 codePage);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
471
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
472 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
473 Log.i(TAG, "sendAidKey() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
474 writeGDS(0, 3, baosp.toByteArray());
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
475 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
476 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
477 Log.w(TAG, ioe.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
478 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
479 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
480 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
481
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
482 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
483 return true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
484 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
485
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
486 private boolean dataIncluded(int aid) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
487 switch (aid) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
488 case PF1:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
489 return !dataIncluded[0];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
490
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
491 case PF2:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
492 return !dataIncluded[1];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
493
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
494 case PF3:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
495 return !dataIncluded[2];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
496
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
497 case PF4:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
498 return !dataIncluded[3];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
499
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
500 case PF5:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
501 return !dataIncluded[4];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
502
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
503 case PF6:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
504 return !dataIncluded[5];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
505
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
506 case PF7:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
507 return !dataIncluded[6];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
508
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
509 case PF8:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
510 return !dataIncluded[7];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
511
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
512 case PF9:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
513 return !dataIncluded[8];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
514
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
515 case PF10:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
516 return !dataIncluded[9];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
517
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
518 case PF11:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
519 return !dataIncluded[10];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
520
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
521 case PF12:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
522 return !dataIncluded[11];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
523
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
524 case PF13:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
525 return !dataIncluded[12];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
526
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
527 case PF14:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
528 return !dataIncluded[13];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
529
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
530 case PF15:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
531 return !dataIncluded[14];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
532
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
533 case PF16:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
534 return !dataIncluded[15];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
535
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
536 case PF17:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
537 return !dataIncluded[16];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
538
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
539 case PF18:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
540 return !dataIncluded[17];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
541
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
542 case PF19:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
543 return !dataIncluded[18];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
544
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
545 case PF20:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
546 return !dataIncluded[19];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
547
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
548 case PF21:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
549 return !dataIncluded[20];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
550
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
551 case PF22:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
552 return !dataIncluded[21];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
553
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
554 case PF23:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
555 return !dataIncluded[22];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
556
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
557 case PF24:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
558 return !dataIncluded[23];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
559
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
560 default:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
561 return true;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
562 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
563 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
564
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
565 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
566 * Help request -
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
567 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
568 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
569 * See notes inside method
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
570 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
571 public final void sendHelpRequest() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
572 // Client sends header 000D12A0000004000003####F3FFEF
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
573 // operation code 3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
574 // row - first ##
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
575 // column - second ##
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
576 // F3 - Help Aid Key
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
577 baosp.write(screen52.getCurrentRow());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
578 baosp.write(screen52.getCurrentCol());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
579 baosp.write(AID_HELP);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
580
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
581 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
582 Log.i(TAG, "sendHelpRequest() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
583 writeGDS(0, 3, baosp.toByteArray());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
584 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
585 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
586 Log.w(TAG, ioe.getMessage());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
587 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
588
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
589 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
590 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
591
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
592 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
593 * Attention Key -
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
594 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
595 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
596 * See notes inside method
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
597 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
598 public final void sendAttentionKey() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
599 // Client sends header 000A12A000004400000FFEF
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
600 // 0x40 -> 01000000
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
601 //
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
602 // flags
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
603 // bit 0 - ERR
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
604 // bit 1 - ATN Attention
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
605 // bits 2-4 - reserved
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
606 // bit 5 - SRQ system request
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
607 // bit 6 - TRQ Test request key
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
608 // bit 7 - HLP
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
609 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
610 Log.i(TAG, "sendAttentionKey() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
611 writeGDS(0x40, 0, null);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
612 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
613 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
614 Log.w(TAG, ioe.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
615 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
616 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
617
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
618 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
619 * Opens a dialog and asks the user before sending a request
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
620 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
621 * @see {@link #systemRequest(String)}
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
622 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
623 public final void systemRequest() {
23
cfcb8d9859a8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 20
diff changeset
624 String ask = manager.res.getString(R.string.prompt_sys_request);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
625 String sysreq = bridge.promptHelper.requestStringPrompt(null, ask);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
626 systemRequest(sysreq);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
627 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
628
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
629 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
630 * @param sr - system request option
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
631 * @see {@link #systemRequest(String)}
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
632 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
633 public final void systemRequest(char sr) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
634 systemRequest(Character.toString(sr));
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
635 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
636
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
637 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
638 * System request, taken from the rfc1205, 5250 Telnet interface section 4.3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
639 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
640 * @param sr system request option (allowed to be null, but than nothing happens)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
641 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
642 public final void systemRequest(String sr) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
643 byte[] bytes = null;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
644
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
645 if ((sr != null) && (sr.length() > 0)) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
646 // XXX: Not sure, if this is a sufficient check for 'clear dataq'
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
647 if (sr.charAt(0) == '2') {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
648 dsq.clear();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
649 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
650
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
651 for (int i = 0, l = sr.length(); i < l; i++) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
652 baosp.write(codePage.uni2ebcdic(sr.charAt(i)));
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
653 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
654
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
655 bytes = baosp.toByteArray();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
656 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
657
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
658 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
659 Log.i(TAG, "systemRequest() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
660 writeGDS(4, 0, bytes);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
661 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
662 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
663 Log.i(TAG, ioe.getMessage());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
664 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
665
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
666 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
667 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
668
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
669 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
670 * Cancel Invite - taken from the rfc1205 - 5250 Telnet interface section
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
671 * 4.3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
672 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
673 * See notes inside method
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
674 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
675 public final void cancelInvite() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
676 // screen52.setStatus(Screen5250.STATUS_SYSTEM,
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
677 // Screen5250.STATUS_VALUE_ON, null);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
678 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
679 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
680
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
681 // from rfc1205 section 4.3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
682 // Server: Sends header with the 000A12A0 00000400 000AFFEF
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
683 // Opcode = Cancel Invite.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
684
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
685 // Client: sends header with the 000A12A0 00000400 000AFFEF
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
686 // Opcode = Cancel Invite to
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
687 // indicate that the work station is
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
688 // no longer invited.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
689 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
690 Log.i(TAG, "cancelInvite() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
691 writeGDS(0, 10, null);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
692 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
693 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
694 Log.w(TAG, ioe.getMessage());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
695 }
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
696 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
697
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
698 public final void hostPrint(int aid) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
699 if (screen52.isStatusErrorCode()) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
700 screen52.restoreErrorLine();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
701 screen52.setStatus(Screen5250.STATUS_ERROR_CODE,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
702 Screen5250.STATUS_VALUE_OFF, null);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
703 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
704
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
705 screen52.setCursorActive(false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
706 // screen52.setStatus(Screen5250.STATUS_SYSTEM,
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
707 // Screen5250.STATUS_VALUE_ON, null);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
708 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
709 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
710 // From client access ip capture
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
711 // it seems to use an operation code of 3 and 4
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
712 // also note that the flag field that says reserved is being sent as
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
713 // well
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
714 // with a value of 0x80
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
715 //
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
716 // I have tried with not setting these flags and sending with 3 or 1
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
717 // there is no effect and I still get a host print screen. Go figure
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
718 //0000: 000D 12A0 0000 0400 8003 1407 F6FFEF
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
719 //0000: 000D 12A0 0000 0400 8001 110E F6FFEF
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
720 //
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
721 // Client sends header 000D12A0000004000003####F6FFEF
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
722 // operation code 3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
723 // row - first ##
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
724 // column - second ##
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
725 // F6 - Print Aid Key
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
726 baosp.write(screen52.getCurrentRow());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
727 baosp.write(screen52.getCurrentCol());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
728 baosp.write(AID_PRINT); // aid key
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
729
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
730 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
731 Log.i(TAG, "hostPrint() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
732 writeGDS(0, 3, baosp.toByteArray());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
733 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
734 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
735 Log.w(TAG, ioe.getMessage());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
736 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
737
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
738 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
739 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
740
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
741 public final void toggleDebug() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
742 producer.toggleDebug(codePage);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
743 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
744
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
745 // write gerneral data stream
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
746 private final void writeGDS(int flags, int opcode, byte abyte0[])
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
747 throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
748 // Added to fix for JDK 1.4 this was null coming from another method.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
749 // There was a weird keyRelease event coming from another panel when
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
750 // using a key instead of the mouse to select button.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
751 // The other method was fixed as well but this check should be here
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
752 // anyway.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
753 if (bout == null)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
754 return;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
755
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
756 int length;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
757
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
758 if (abyte0 != null)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
759 length = abyte0.length + 10;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
760 else
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
761 length = 10;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
762
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
763 // refer to rfc1205 - 5250 Telnet interface
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
764 // Section 3. Data Stream Format
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
765 // Logical Record Length - 16 bits
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
766 baosrsp.write(length >> 8); // Length LL
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
767 baosrsp.write(length & 0xff); // LL
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
768 // Record Type - 16 bits
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
769 // It should always be set to '12A0'X to indicate the
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
770 // General Data Stream (GDS) record type.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
771 baosrsp.write(18); // 0x12
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
772 baosrsp.write(160); // 0xA0
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
773 // the next 16 bits are not used
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
774 baosrsp.write(0); // 0x00
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
775 baosrsp.write(0); // 0x00
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
776 // The second part is meant to be variable in length
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
777 // currently this portion is 4 octets long (1 byte or 8 bits for us ;-O)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
778 baosrsp.write(4); // 0x04
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
779 baosrsp.write(flags); // flags
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
780 // bit 0 - ERR
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
781 // bit 1 - ATN Attention
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
782 // bits 2-4 - reserved
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
783 // bit 5 - SRQ system request
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
784 // bit 6 - TRQ Test request key
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
785 // bit 7 - HLP
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
786 baosrsp.write(0); // reserved - set to 0x00
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
787 baosrsp.write(opcode); // opcode
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
788
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
789 if (abyte0 != null)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
790 baosrsp.write(abyte0, 0, abyte0.length);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
791
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
792 baosrsp = appendByteStream(baosrsp.toByteArray());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
793 // make sure we indicate no more to be sent
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
794 baosrsp.write(IAC);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
795 baosrsp.write(EOR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
796 baosrsp.writeTo(bout);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
797 bout.flush();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
798 baosrsp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
799 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
800
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
801 protected final int getOpCode() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
802 return bk.getOpCode();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
803 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
804
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
805 protected boolean[] getActiveAidKeys() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
806 boolean aids[] = new boolean[dataIncluded.length];
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
807 System.arraycopy(dataIncluded, 0, aids, 0, dataIncluded.length);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
808 return aids;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
809 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
810
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
811 private final void setInvited() {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
812 Log.d(TAG, "invited");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
813 if (!screen52.isStatusErrorCode())
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
814 screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
815 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
816 invited = true;
424
09c1d3aae3f0 updateDirty before testChanged, try to eliminate sending duplicate screenChanged to the monitor
Carl Byington <carl@five-ten-sg.com>
parents: 414
diff changeset
817 screen52.updateDirty();
392
7ac1a0b02f44 add test buffer changed when input stream runs dry, similar to async test
Carl Byington <carl@five-ten-sg.com>
parents: 390
diff changeset
818 buffer.testChanged();
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
819 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
820
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
821 // WVL - LDC : 05/08/2005 : TFX.006253 - Support STRPCCMD
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
822 private void strpccmd() {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
823 try {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
824 int str = 11;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
825 char c;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
826 ScreenPlanes planes = screen52.getPlanes();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
827 c = planes.getChar(str);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
828 boolean waitFor = !(c == 'a');
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
829 StringBuilder command = new StringBuilder();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
830
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
831 for (int i = str + 1; i < 132; i++) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
832 c = planes.getChar(i);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
833
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
834 if (Character.isISOControl(c))
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
835 c = ' ';
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
836
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
837 command.append(c);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
838 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
839
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
840 String cmd = command.toString().trim();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
841 run(cmd, waitFor);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
842 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
843 finally {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
844 strpccmd = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
845 screen52.sendKeys(TN5250jConstants.MNEMONIC_ENTER);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
846 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
847 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
848
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
849 // WVL - LDC : 05/08/2005 : TFX.006253 - Support STRPCCMD
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
850 private void run(String cmd, boolean waitFor) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
851 try {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
852 Log.d(TAG, "RUN cmd = " + cmd);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
853 Log.d(TAG, "RUN wait = " + waitFor);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
854 Runtime r = Runtime.getRuntime();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
855 Process p = r.exec(cmd);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
856
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
857 if (waitFor) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
858 int result = p.waitFor();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
859 Log.d(TAG, "RUN result = " + result);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
860 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
861 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
862 catch (Throwable t) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
863 Log.e(TAG, "exception", t);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
864 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
865 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
866
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
867
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
868 // WVL - LDC : TR.000300 : Callback scenario from 5250
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
869 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
870 * Activate or deactivate the command scanning behaviour.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
871 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
872 * @param scan
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
873 * if true, scanning is enabled; disabled otherwise.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
874 *
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
875 * @see #scan()
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
876 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
877 public void setScanningEnabled(boolean scan) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
878 this.scan = scan;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
879 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
880
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
881 // WVL - LDC : TR.000300 : Callback scenario from 5250
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
882 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
883 * Checks whether command scanning is enabled.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
884 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
885 * @return true is command scanning is enabled; false otherwise.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
886 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
887 public boolean isScanningEnabled() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
888 return this.scan;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
889 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
890
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
891 // WVL - LDC : TR.000300 : Callback scenario from 5250
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
892 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
893 * When command scanning is activated, the terminal reads the first and
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
894 * second character in the datastream (the zero position allows to
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
895 * devisualize the scan stream). If the sequence <code>#!</code> is
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
896 * encountered and if this sequence is <strong>not </strong> followed by a
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
897 * blank character, the {@link parseCommand()}is called.
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
898 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
899 private void scan() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
900 // screen52.screen[1].getChar() + screen52.screen[2].getChar());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
901 // ScreenChar[] screen = screen52.screen;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
902 ScreenPlanes planes = screen52.getPlanes();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
903
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
904 if ((planes.getChar(STRSCAN) == '#')
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
905 && (planes.getChar(STRSCAN + 1) == '!')
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
906 && (planes.getChar(STRSCAN + 2) != ' ')) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
907 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
908 parseCommand();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
909 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
910 catch (Throwable t) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
911 Log.i(TAG, "Exec cmd: " + t.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
912 t.printStackTrace();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
913 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
914 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
915 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
916
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
917 // WVL - LDC : TR.000300 : Callback scenario from 5250
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
918 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
919 * The screen is parsed starting from second position until a white space is
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
920 * encountered. When found the Session#execCommand(String, int) is
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
921 * called with the parsed string. The position immediately following the
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
922 * encountered white space, separating the command from the rest of the
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
923 * screen, is passed as starting index.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
924 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
925 * Note that the character at the starting position can potentially be a
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
926 * white space itself. The starting position in <code>execCommand</code>
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
927 * provided to make the scanning sequence more flexible. We'd like for
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
928 * example to embed also a <code>+</code> or <code>-</code> sign to
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
929 * indicate whether the tnvt should trigger a repaint or not. This would
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
930 * allow the flashing of command sequences without them becoming visible.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
931 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
932 * <ul>
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
933 * <li><strong>PRE </strong> The screen character at position
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
934 * <code>STRSCAN + 2</code> is not a white space.</li>
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
935 * </ul>
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
936 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
937 private void parseCommand() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
938 // Search for the command i.e. the first token in the stream
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
939 // after the #! sequence separated by a space from the rest
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
940 // of the screen.
32
b086dd794dba start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 29
diff changeset
941 char[] screen = screen52.getScreenAsChars();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
942
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
943 for (int s = STRSCAN + 2, i = s; i < screen.length; i++) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
944 if (screen[i] == ' ') {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
945 String command = new String(screen, s, i - s);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
946 // Skip all white spaces between the command and the rest of
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
947 // the screen.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
948 //for (; (i < screen.length) && (screen[i] == ' '); i++);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
949 String remainder = new String(screen, i + 1, screen.length
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
950 - (i + 1));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
951 //controller.fireScanned(command, remainder);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
952 Log.i(TAG, "trying to run " + command + " " + remainder);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
953 break;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
954 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
955 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
956 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
957
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
958 public void run() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
959 if (enhanced) sfParser = new WTDSFParser(this);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
960
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
961 bk = new Stream5250();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
962
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
963 while (keepTrucking) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
964 try {
214
3e68cb17c0b6 socket runs dry sends flag to tnvt to call testChanged()
Carl Byington <carl@five-ten-sg.com>
parents: 125
diff changeset
965 Object e = dsq.take();
392
7ac1a0b02f44 add test buffer changed when input stream runs dry, similar to async test
Carl Byington <carl@five-ten-sg.com>
parents: 390
diff changeset
966
7ac1a0b02f44 add test buffer changed when input stream runs dry, similar to async test
Carl Byington <carl@five-ten-sg.com>
parents: 390
diff changeset
967 if ((e instanceof Integer) && ((Integer)e == 0)) {
424
09c1d3aae3f0 updateDirty before testChanged, try to eliminate sending duplicate screenChanged to the monitor
Carl Byington <carl@five-ten-sg.com>
parents: 414
diff changeset
968 screen52.updateDirty();
392
7ac1a0b02f44 add test buffer changed when input stream runs dry, similar to async test
Carl Byington <carl@five-ten-sg.com>
parents: 390
diff changeset
969 buffer.testChanged();
7ac1a0b02f44 add test buffer changed when input stream runs dry, similar to async test
Carl Byington <carl@five-ten-sg.com>
parents: 390
diff changeset
970 continue;
7ac1a0b02f44 add test buffer changed when input stream runs dry, similar to async test
Carl Byington <carl@five-ten-sg.com>
parents: 390
diff changeset
971 };
7ac1a0b02f44 add test buffer changed when input stream runs dry, similar to async test
Carl Byington <carl@five-ten-sg.com>
parents: 390
diff changeset
972
99
eda03b809f48 move blocking test from socket read to queue take
Carl Byington <carl@five-ten-sg.com>
parents: 91
diff changeset
973 bk.initialize((byte[])e);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
974 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
975 catch (InterruptedException ie) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
976 Log.w(TAG, " vt thread interrupted and stopping ");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
977 keepTrucking = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
978 continue;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
979 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
980
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
981 invited = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
982 screen52.setCursorActive(false);
216
cd07c1648016 test buffer changed when 5250 keyboard unlocks
Carl Byington <carl@five-ten-sg.com>
parents: 215
diff changeset
983 if (bk == null) continue;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
984
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
985 switch (bk.getOpCode()) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
986 case 00:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
987 Log.d(TAG, "No operation");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
988 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
989
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
990 case 1:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
991 Log.d(TAG, "Invite Operation");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
992 parseIncoming();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
993 pendingUnlock = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
994 cursorOn = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
995 setInvited();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
996 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
997
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
998 case 2:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
999 Log.d(TAG, "Output Only");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1000 parseIncoming();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1001 screen52.updateDirty();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1002 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1003
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1004 case 3:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1005 Log.d(TAG, "Put/Get Operation");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1006 parseIncoming();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1007 setInvited();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1008 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1009
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1010 case 4:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1011 Log.d(TAG, "Save Screen Operation");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1012 parseIncoming();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1013 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1014
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1015 case 5:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1016 Log.d(TAG, "Restore Screen Operation");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1017 parseIncoming();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1018 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1019
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1020 case 6:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1021 Log.d(TAG, "Read Immediate");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1022 sendAidKey(0);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1023 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1024
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1025 case 7:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1026 Log.d(TAG, "Reserved");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1027 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1028
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1029 case 8:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1030 Log.d(TAG, "Read Screen Operation");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1031
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1032 try {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1033 readScreen();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1034 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1035 catch (IOException ex) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1036 Log.w(TAG, ex.getMessage());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1037 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1038
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1039 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1040
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1041 case 9:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1042 Log.d(TAG, "Reserved");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1043 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1044
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1045 case 10:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1046 Log.d(TAG, "Cancel Invite Operation");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1047 cancelInvite();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1048 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1049
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1050 case 11:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1051 Log.d(TAG, "Turn on message light");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1052 screen52.getOIA().setMessageLightOn();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1053 screen52.setCursorActive(true);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1054 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1055
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1056 case 12:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1057 Log.d(TAG, "Turn off Message light");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1058 screen52.getOIA().setMessageLightOff();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1059 screen52.setCursorActive(true);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1060 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1061
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1062 default:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1063 break;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1064 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1065
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1066 if (screen52.isUsingGuiInterface())
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1067 screen52.drawFields();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1068
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1069 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1070 if (!strpccmd) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1071 screen52.updateDirty();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1072 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1073 else {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1074 strpccmd();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1075 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1076 }
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1077 catch (RuntimeException e) {
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1078 Log.w(TAG, " tnvt.run: " + e.getMessage());
446
5ce5235adde6 fix compile errors
Carl Byington <carl@five-ten-sg.com>
parents: 445
diff changeset
1079 e.printStackTrace();
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1080 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1081
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1082 if (pendingUnlock && !screen52.isStatusErrorCode()) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1083 screen52.getOIA().setKeyBoardLocked(false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1084 pendingUnlock = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1085 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1086
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1087 if (cursorOn && !screen52.getOIA().isKeyBoardLocked()) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1088 screen52.setCursorActive(true);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1089 cursorOn = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1090 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1091 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1092 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1093
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1094 public void dumpStuff() {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1095 Log.d(TAG, " Pending unlock " + pendingUnlock);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1096 Log.d(TAG, " Status Error " + screen52.isStatusErrorCode());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1097 Log.d(TAG, " Keyboard Locked " + screen52.getOIA().isKeyBoardLocked());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1098 Log.d(TAG, " Cursor On " + cursorOn);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1099 Log.d(TAG, " Cursor Active " + screen52.cursorActive);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1100 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1101
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1102
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1103 private final void readScreen() throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1104 int rows = screen52.getRows();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1105 int cols = screen52.getColumns();
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1106 byte screenArray[] = new byte[rows * cols];
446
5ce5235adde6 fix compile errors
Carl Byington <carl@five-ten-sg.com>
parents: 445
diff changeset
1107 fillScreenArray(screenArray);
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
1108 Log.i(TAG, "readScreen() writeGDS()");
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1109 writeGDS(0, 0, screenArray);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1110 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1111
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1112 private final void fillScreenArray(byte[] sa) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1113 ScreenPlanes planes = screen52.planes;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1114
405
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1115 try {
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1116 for (int i = 0; i < sa.length; i++) { // save the screen data
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1117 if (planes.isAttributePlace(i)) {
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1118 sa[i] = (byte) planes.getCharAttr(i);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1119 }
405
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1120 else {
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1121 // The characters on screen are in unicode
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1122 char ch = planes.getChar(i);
405
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1123 byte byteCh;
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1124 if (isDataUnicode(ch)) byteCh = codePage.uni2ebcdic(ch);
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1125 else byteCh = (byte) ch;
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1126 sa[i] = byteCh;
405
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1127 }
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1128 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1129 }
405
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1130 catch (Exception exc) {
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1131 Log.i(TAG, exc.getMessage());
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1132 exc.printStackTrace();
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1133 }
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1134 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1135
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1136 private byte[] createRegenerationBuffer(int len) throws IOException {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1137 int la = 32;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1138 int sac = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1139 ScreenPlanes planes = screen52.planes;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1140 byte[] sa = new byte[len];
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1141
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1142 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1143 boolean guiExists = sfParser != null && sfParser.isGuisExists();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1144
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1145 for (int i = 0; i < len; i++) { // save the screen data
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1146 if (guiExists) {
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1147 byte[] guiSeg = sfParser.getSegmentAtPos(i);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1148
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1149 if (guiSeg != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1150 //Log.i(TAG," gui saved at " + y + " - " + screen52.getRow(y) + "," +
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1151 // screen52.getCol(y));
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1152 byte[] gsa = new byte[sa.length + guiSeg.length + 2];
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1153 System.arraycopy(sa, 0, gsa, 0, sa.length);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1154 System.arraycopy(guiSeg, 0, gsa, sac + 2, guiSeg.length);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1155 sa = new byte[gsa.length];
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1156 System.arraycopy(gsa, 0, sa, 0, gsa.length);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1157 sa[sac++] = (byte)0x04;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1158 sa[sac++] = (byte)0x11;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1159 sac += guiSeg.length;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1160 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1161 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1162
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1163 if (planes.isAttributePlace(i)) {
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1164 la = planes.getCharAttr(i);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1165 sa[sac++] = (byte) la;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1166 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1167 else {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1168 // The characters on screen are in unicode
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1169 char ch = planes.getChar(i);
405
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1170 byte byteCh;
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1171 if (isDataUnicode(ch)) byteCh = codePage.uni2ebcdic(ch);
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1172 else byteCh = (byte) ch;
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1173 sa[sac++] = byteCh;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1174 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1175 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1176 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1177 catch (Exception exc) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1178 Log.i(TAG, exc.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1179 exc.printStackTrace();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1180 }
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1181 return sa;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1182 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1183
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1184 public final void saveScreen() throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1185 ByteArrayOutputStream sc = new ByteArrayOutputStream();
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1186 sc.write(new byte[] {4, 0x12, 0, 0});
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1187 sc.write((byte) screen52.getRows()); // store the current size
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1188 sc.write((byte) screen52.getColumns()); // ""
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1189 int cp = screen52.getCurrentPos(); // save off current position
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1190 sc.write((byte)(cp >> 8 & 0xff)); // ""
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1191 sc.write((byte)(cp & 0xff)); // ""
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1192 sc.write((byte)(screen52.homePos >> 8 & 0xff)); // save home pos
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1193 sc.write((byte)(screen52.homePos & 0xff)); // ""
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1194 sc.write(createRegenerationBuffer(screen52.getRows() * screen52.getColumns()));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1195 int sizeFields = screen52.getScreenFields().getSize();
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1196 sc.write((byte)(sizeFields >> 8 & 0xff)); // save number of fields
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1197 sc.write((byte)(sizeFields & 0xff)); // ""
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1198
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1199 if (sizeFields > 0) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1200 int x = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1201 int s = screen52.getScreenFields().getSize();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1202
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1203 while (x < s) {
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1204 ScreenField sf = screen52.getScreenFields().getField(x);
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1205 sc.write((byte) sf.getAttr()); // attribute
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1206 int sp = sf.startPos();
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1207 sc.write((byte)(sp >> 8 & 0xff)); // position
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1208 sc.write((byte)(sp & 0xff)); // ""
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1209
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1210 if (sf.mdt)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1211 sc.write((byte) 1);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1212 else
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1213 sc.write((byte) 0);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1214
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1215 sc.write((byte)(sf.getLength() >> 8 & 0xff));
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
1216 sc.write((byte)(sf.getLength() & 0xff));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1217 sc.write((byte) sf.getFFW1() & 0xff);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1218 sc.write((byte) sf.getFFW2() & 0xff);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1219 sc.write((byte) sf.getFCW1() & 0xff);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1220 sc.write((byte) sf.getFCW2() & 0xff);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1221 Log.d(TAG, "Saved ");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1222 Log.d(TAG, sf.toString());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1223 x++;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1224 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1225 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1226
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1227 // The following two lines of code looks to have caused all sorts of
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1228 // problems so for now we have commented them out.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1229 // screen52.getScreenFields().setCurrentField(null); // set it to null
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1230 // for GC ?
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1231 // screen52.clearTable();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1232
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1233 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
1234 Log.i(TAG, "saveScreen() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1235 writeGDS(0, 3, sc.toByteArray());
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1236 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1237 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1238 Log.w(TAG, ioe.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1239 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1240 Log.d(TAG, "Save Screen end ");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1241 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1242
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1243 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1244 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1245 * @throws IOException
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1246 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1247 public final void restoreScreen() throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1248 int which = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1249 ScreenPlanes planes = screen52.planes;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1250
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1251 try {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1252 Log.d(TAG, "Restore ");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1253 bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1254 bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1255 int rows = bk.getNextByte() & 0xff;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1256 int cols = bk.getNextByte() & 0xff;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1257 int pos = bk.getNextByte() << 8 & 0xff00; // current position
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1258 pos |= bk.getNextByte() & 0xff;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1259 int hPos = bk.getNextByte() << 8 & 0xff00; // home position
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1260 hPos |= bk.getNextByte() & 0xff;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1261
29
017eeed8332c start tn5250 integration
Carl Byington <carl@five-ten-sg.com>
parents: 27
diff changeset
1262 if ((rows != screen52.getRows()) || (cols != screen52.getColumns()))
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1263 screen52.setRowsCols(rows, cols);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1264
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1265 screen52.clearAll(); // initialize what we currenty have
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1266
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1267 if (sfParser != null && sfParser.isGuisExists())
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1268 sfParser.clearGuiStructs();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1269
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1270 int b = 32;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1271 int la = 32;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1272 int len = rows * cols;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1273
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1274 for (int y = 0; y < len; y++) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1275 b = bk.getNextByte();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1276
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1277 if (b == 0x04) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1278 Log.i(TAG, " gui restored at " + y + " - " + screen52.getRow(y) + "," +
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1279 screen52.getCol(y));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1280 int command = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1281 byte[] seg = bk.getSegment();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1282
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1283 if (seg.length > 0) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1284 screen52.goto_XY(y);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1285 sfParser.parseWriteToDisplayStructuredField(seg);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1286 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1287
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1288 y--;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1289 // screen52.goto_XY(y);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1290 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1291 else {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1292 // b = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1293 if (planes.isUseGui(y))
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1294 continue;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1295
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1296 if (isAttribute(b)) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1297 planes.setScreenCharAndAttr(y, planes.getChar(y), b, true);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1298 la = b;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1299 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1300 else {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1301 // The characters on screen are in unicode
405
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1302 char ch;
d3c5480e8441 fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 392
diff changeset
1303 if (isDataEBCDIC(b)) ch = codePage.ebcdic2uni(b);
406
4038389cb7ce fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents: 405
diff changeset
1304 else ch = (char) b;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1305 planes.setScreenCharAndAttr(y, ch, la, false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1306 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1307 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1308 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1309
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1310 int numFields = bk.getNextByte() << 8 & 0xff00;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1311 numFields |= bk.getNextByte() & 0xff;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1312 Log.d(TAG, "number of fields " + numFields);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1313
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1314 if (numFields > 0) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1315 int x = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1316 int attr = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1317 int fPos = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1318 int fLen = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1319 int ffw1 = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1320 int ffw2 = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1321 int fcw1 = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1322 int fcw2 = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1323 boolean mdt = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1324 ScreenField sf = null;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1325
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1326 while (x < numFields) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1327 attr = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1328 fPos = bk.getNextByte() << 8 & 0xff00;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1329 fPos |= bk.getNextByte() & 0xff;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1330
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1331 if (bk.getNextByte() == 1)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1332 mdt = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1333 else
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1334 mdt = false;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1335
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1336 fLen = bk.getNextByte() << 8 & 0xff00;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1337 fLen |= bk.getNextByte() & 0xff;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1338 ffw1 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1339 ffw2 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1340 fcw1 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1341 fcw2 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1342 sf = screen52.getScreenFields().setField(attr,
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1343 screen52.getRow(fPos), screen52.getCol(fPos), fLen,
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1344 ffw1, ffw2, fcw1, fcw2);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1345
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1346 while (fLen-- > 0) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1347 // now we set the field plane attributes
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1348 planes.setScreenFieldAttr(fPos++, ffw1);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1349 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1350
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1351 if (mdt) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1352 sf.setMDT();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1353 screen52.getScreenFields().setMasterMDT();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1354 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1355
413
da2814f6f05e code cleanup
Carl Byington <carl@five-ten-sg.com>
parents: 406
diff changeset
1356 Log.d(TAG, "Restored ");
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1357 Log.d(TAG, sf.toString());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1358 x++;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1359 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1360 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1361
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1362 // Redraw the gui fields if we are in gui mode
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1363 if (screen52.isUsingGuiInterface())
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1364 screen52.drawFields();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1365
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1366 screen52.restoreScreen(); // display the screen
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1367 // The position was saved with currentPos which 1,1 offset of the
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1368 // screen position.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1369 // The setPendingInsert is the where the cursor position will be
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1370 // displayed after the restore.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1371 screen52.setPendingInsert(true, screen52.getRow(pos + cols), screen52
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1372 .getCol(pos + cols));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1373 // We need to offset the pos by -1 since the position is 1,1 based
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1374 // and the goto_XY is 0,0 based.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1375 screen52.goto_XY(pos - 1);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1376 screen52.isInField();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1377 // // Redraw the gui fields if we are in gui mode
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1378 // if (screen52.isUsingGuiInterface())
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1379 // screen52.drawFields();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1380 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1381 catch (Exception e) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1382 Log.w(TAG, "error restoring screen " + which + " with "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1383 + e.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1384 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1385 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1386
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1387 public final boolean waitingForInput() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1388 return waitingForInput;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1389 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1390
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1391 private void parseIncoming() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1392 boolean done = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1393 boolean error = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1394
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1395 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1396 while (bk.hasNext() && !done) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1397 byte b = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1398
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1399 switch (b) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1400 case 0:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1401 case 1:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1402 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1403
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1404 case CMD_SAVE_SCREEN: // 0x02 2 Save Screen
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1405 case 3: // 0x03 3 Save Partial Screen
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1406 Log.d(TAG, "save screen partial");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1407 saveScreen();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1408 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1409
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1410 case ESC: // ESCAPE
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1411 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1412
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1413 case 7: // audible bell
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1414 manager.playBeep();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1415 bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1416 bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1417 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1418
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1419 case CMD_WRITE_TO_DISPLAY: // 0x11 17 write to display
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1420 error = writeToDisplay(true);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1421
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1422 // WVL - LDC : TR.000300 : Callback scenario from 5250
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1423 // Only scan when WRITE_TO_DISPLAY operation (i.e. refill
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1424 // screen buffer)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1425 // has been issued!
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1426 if (scan)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1427 scan();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1428
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1429 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1430
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1431 case CMD_RESTORE_SCREEN: // 0x12 18 Restore Screen
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1432 case 13: // 0x13 19 Restore Partial Screen
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1433 Log.d(TAG, "restore screen partial");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1434 restoreScreen();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1435 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1436
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1437 case CMD_CLEAR_UNIT_ALTERNATE: // 0x20 32 clear unit alternate
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1438 int param = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1439
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1440 if (param != 0) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1441 Log.d(TAG, " clear unit alternate error "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1442 + Integer.toHexString(param));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1443 sendNegResponse(NR_REQUEST_ERROR, 03, 01, 05,
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1444 " clear unit alternate not supported");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1445 done = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1446 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1447 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1448 if (screen52.getRows() != 27)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1449 screen52.setRowsCols(27, 132);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1450
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1451 screen52.clearAll();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1452
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1453 if (sfParser != null && sfParser.isGuisExists())
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1454 sfParser.clearGuiStructs();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1455 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1456
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1457 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1458
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1459 case CMD_WRITE_ERROR_CODE: // 0x21 33 Write Error Code
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1460 writeErrorCode();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1461 error = writeToDisplay(false);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1462 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1463
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1464 case CMD_WRITE_ERROR_CODE_TO_WINDOW: // 0x22 34
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1465 // Write Error Code to window
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1466 writeErrorCodeToWindow();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1467 error = writeToDisplay(false);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1468 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1469
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1470 case CMD_READ_SCREEN_IMMEDIATE: // 0x62 98
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1471 case CMD_READ_SCREEN_TO_PRINT: // 0x66 102 read screen to print
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1472 readScreen();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1473 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1474
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1475 case CMD_CLEAR_UNIT: // 64 0x40 clear unit
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1476 if (screen52.getRows() != 24)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1477 screen52.setRowsCols(24, 80);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1478
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1479 screen52.clearAll();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1480
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1481 if (sfParser != null && sfParser.isGuisExists())
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1482 sfParser.clearGuiStructs();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1483
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1484 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1485
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1486 case CMD_CLEAR_FORMAT_TABLE: // 80 0x50 Clear format table
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1487 screen52.clearTable();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1488 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1489
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1490 case CMD_READ_INPUT_FIELDS: //0x42 66 read input fields
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1491 case CMD_READ_MDT_FIELDS: // 0x52 82 read MDT Fields
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1492 bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1493 bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1494 readType = b;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1495 screen52.goHome();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1496 // do nothing with the cursor here it is taken care of
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1497 // in the main loop.
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1498 //////////////// screen52.setCursorOn();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1499 waitingForInput = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1500 pendingUnlock = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1501 // screen52.setKeyboardLocked(false);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1502 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1503
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1504 case CMD_READ_MDT_IMMEDIATE_ALT: // 0x53 83
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1505 readType = b;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1506 // screen52.goHome();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1507 // waitingForInput = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1508 // screen52.setKeyboardLocked(false);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1509 readImmediate(readType);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1510 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1511
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1512 case CMD_WRITE_STRUCTURED_FIELD: // 243 0xF3 -13 Write
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1513 // structured field
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1514 writeStructuredField();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1515 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1516
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1517 case CMD_ROLL: // 0x23 35 Roll Not sure what it does right now
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1518 int updown = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1519 int topline = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1520 int bottomline = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1521 screen52.rollScreen(updown, topline, bottomline);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1522 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1523
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1524 default:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1525 done = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1526 sendNegResponse(NR_REQUEST_ERROR, 03, 01, 01,
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1527 "parseIncoming");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1528 break;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1529 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1530
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1531 if (error)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1532 done = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1533 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1534 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1535 catch (Exception exc) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1536 Log.w(TAG, "incoming " + exc.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1537 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1538 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1539
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1540 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1541 * This routine handles sending negative responses back to the host.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1542 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1543 * You can find a description of the types of responses to be sent back by
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1544 * looking at section 12.4 of the 5250 Functions Reference manual
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1545 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1546 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1547 * @param cat
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1548 * @param modifier
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1549 * @param uByte1
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1550 * @param uByte2
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1551 * @param from
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1552 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1553 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1554 protected void sendNegResponse(int cat, int modifier, int uByte1,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1555 int uByte2, String from) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1556 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1557 int os = bk.getByteOffset(-1) & 0xf0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1558 int cp = (bk.getCurrentPos() - 1);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1559 Log.i(TAG, "invalid " + from + " command " + os
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1560 + " at pos " + cp);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1561 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1562 catch (Exception e) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1563 Log.w(TAG, "Send Negative Response error " + e.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1564 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1565
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1566 baosp.write(cat);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1567 baosp.write(modifier);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1568 baosp.write(uByte1);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1569 baosp.write(uByte2);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1570
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1571 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
1572 Log.i(TAG, "sendNegResponse() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1573 writeGDS(128, 0, baosp.toByteArray());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1574 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1575 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1576 Log.w(TAG, ioe.getMessage());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1577 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1578
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1579 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1580 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1581
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1582 public void sendNegResponse2(int ec) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1583 screen52.setPrehelpState(true, true, false);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1584 baosp.write(0x00);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1585 baosp.write(ec);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1586
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1587 try {
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
1588 Log.i(TAG, "sendNegResponse2() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1589 writeGDS(1, 0, baosp.toByteArray());
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1590 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1591 catch (IOException ioe) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1592 Log.w(TAG, ioe.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1593 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1594
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1595 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1596 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1597
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1598 private boolean writeToDisplay(boolean controlsExist) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1599 boolean error = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1600 boolean done = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1601 int attr;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1602 byte control0 = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1603 byte control1 = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1604 int saRows = screen52.getRows();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1605 int saCols = screen52.getColumns();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1606
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1607 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1608 if (controlsExist) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1609 control0 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1610 control1 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1611 processCC0(control0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1612 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1613
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1614 while (bk.hasNext() && !done) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1615 // pos = bk.getCurrentPos();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1616 // int rowc = screen52.getCurrentRow();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1617 // int colc = screen52.getCurrentCol();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1618 byte bytebk = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1619
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1620 switch (bytebk) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1621 case 1: // SOH - Start of Header Order
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1622 Log.d(TAG, "SOH - Start of Header Order");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1623 error = processSOH();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1624 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1625
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1626 case 02: // RA - Repeat to address
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1627 Log.d(TAG, "RA - Repeat to address");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1628 int row = screen52.getCurrentRow();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1629 int col = screen52.getCurrentCol();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1630 int toRow = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1631 int toCol = bk.getNextByte() & 0xff;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1632
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1633 if (toRow >= row) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1634 int repeat = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1635
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1636 // a little intelligence here I hope
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1637 if (row == 1 && col == 2 && toRow == screen52.getRows()
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1638 && toCol == screen52.getColumns())
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1639 screen52.clearScreen();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1640 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1641 if (repeat != 0) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1642 //LDC - 13/02/2003 - convert it to unicode
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1643 repeat = codePage.ebcdic2uni(repeat);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1644 //repeat = getASCIIChar(repeat);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1645 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1646
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1647 int times = ((toRow * screen52.getColumns()) + toCol)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1648 - ((row * screen52.getColumns()) + col);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1649
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1650 while (times-- >= 0) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1651 screen52.setChar(repeat);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1652 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1653 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1654 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1655 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1656 sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x23,
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1657 " RA invalid");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1658 error = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1659 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1660
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1661 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1662
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1663 case 03: // EA - Erase to address
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1664 Log.d(TAG, "EA - Erase to address");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1665 int EArow = screen52.getCurrentRow();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1666 int EAcol = screen52.getCurrentCol();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1667 int toEARow = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1668 int toEACol = bk.getNextByte() & 0xff;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1669 int EALength = bk.getNextByte() & 0xff;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1670
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1671 while (--EALength > 0) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1672 bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1673 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1674
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1675 char EAAttr = (char) 0;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1676
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1677 // a little intelligence here I hope
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1678 if (EArow == 1 && EAcol == 2
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1679 && toEARow == screen52.getRows()
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1680 && toEACol == screen52.getColumns())
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1681 screen52.clearScreen();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1682 else {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1683 int times = ((toEARow * screen52.getColumns()) + toEACol)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1684 - ((EArow * screen52.getColumns()) + EAcol);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1685
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1686 while (times-- >= 0) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1687 screen52.setChar(EAAttr);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1688 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1689 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1690
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1691 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1692
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1693 case 04: // Command - Escape
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1694 Log.d(TAG, "Command - Escape");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1695 done = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1696 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1697
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1698 case 16: // TD - Transparent Data
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1699 Log.d(TAG, "TD - Transparent Data");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1700 int j = (bk.getNextByte() & 0xff) << 8 | bk.getNextByte()
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1701 & 0xff; // length
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1702 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1703
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1704 case 17: // SBA - set buffer address order (row column)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1705 //Log.d(TAG,"SBA - set buffer address order (row column)");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1706 int saRow = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1707 int saCol = bk.getNextByte() & 0xff;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1708
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1709 // make sure it is in bounds
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1710 if (saRow >= 0 && saRow <= screen52.getRows() && saCol >= 0
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1711 && saCol <= screen52.getColumns()) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1712 screen52.setCursor(saRow, saCol); // now set screen
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1713 // position for output
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1714 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1715 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1716 sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22,
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1717 "invalid row/col order" + " saRow = " + saRow
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1718 + " saRows = " + screen52.getRows()
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1719 + " saCol = " + saCol);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1720 error = true;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1721 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1722
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1723 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1724
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1725 case 18: // WEA - Extended Attribute
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1726 Log.d(TAG, "WEA - Extended Attribute");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1727 bk.getNextByte();
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1728 bk.getNextByte();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1729 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1730
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1731 case 19: // IC - Insert Cursor
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1732 Log.d(TAG, "IC - Insert Cursor");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1733 int icX = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1734 int icY = bk.getNextByte() & 0xff;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1735
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1736 if (icX >= 0 && icX <= saRows && icY >= 0 && icY <= saCols) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1737 Log.d(TAG, " IC " + icX + " " + icY);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1738 screen52.setPendingInsert(true, icX, icY);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1739 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1740 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1741 sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22,
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1742 " IC/IM position invalid ");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1743 error = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1744 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1745
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1746 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1747
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1748 case 20: // MC - Move Cursor
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1749 Log.d(TAG, "MC - Move Cursor");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1750 int imcX = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1751 int imcY = bk.getNextByte() & 0xff;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1752
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1753 if (imcX >= 0 && imcX <= saRows && imcY >= 0
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1754 && imcY <= saCols) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1755 Log.d(TAG, " MC " + imcX + " " + imcY);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1756 screen52.setPendingInsert(false, imcX, imcY);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1757 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1758 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1759 sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22,
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1760 " IC/IM position invalid ");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1761 error = true;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1762 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1763
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1764 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1765
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1766 case 21: // WTDSF - Write To Display Structured Field order
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1767 Log.d(TAG, "WTDSF - Write To Display Structured Field order");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1768 byte[] seg = bk.getSegment();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1769 error = sfParser.parseWriteToDisplayStructuredField(seg);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1770 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1771
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1772 case 29: // SF - Start of Field
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1773 Log.d(TAG, "SF - Start of Field");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1774 int fcw1 = 0;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1775 int fcw2 = 0;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1776 int ffw1 = 0;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1777 int ffw0 = bk.getNextByte() & 0xff; // FFW
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1778
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1779 if ((ffw0 & 0x40) == 0x40) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1780 ffw1 = bk.getNextByte() & 0xff; // FFW 1
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1781 fcw1 = bk.getNextByte() & 0xff; // check for field
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1782
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1783 // control word
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1784
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1785 // check if the first fcw1 is an 0x81 if it is then get
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1786 // the next pair for checking
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1787 if (fcw1 == 0x81) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1788 bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1789 fcw1 = bk.getNextByte() & 0xff; // check for field
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1790 // control word
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1791 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1792
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1793 if (!isAttribute(fcw1)) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1794 fcw2 = bk.getNextByte() & 0xff; // FCW 2
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1795 attr = bk.getNextByte() & 0xff; // attribute field
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1796
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1797 while (!isAttribute(attr)) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1798 Log.i(TAG, Integer.toHexString(fcw1) + " "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1799 + Integer.toHexString(fcw2)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1800 + " ");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1801 Log.i(TAG, Integer.toHexString(attr)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1802 + " "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1803 + Integer.toHexString(bk
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1804 .getNextByte() & 0xff));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1805 attr = bk.getNextByte() & 0xff; // attribute field
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1806 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1807 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1808 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1809 attr = fcw1; // attribute of field
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1810 fcw1 = 0;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1811 }
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1812 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1813 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1814 attr = ffw0;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1815 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1816
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1817 int fLength = (bk.getNextByte() & 0xff) << 8
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1818 | bk.getNextByte() & 0xff;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1819 screen52.addField(attr, fLength, ffw0, ffw1, fcw1, fcw2);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1820 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1821
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1822 // WVL - LDC : 05/08/2005 : TFX.006253 - Support STRPCCMD
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1823 case -128: //STRPCCMD
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1824 // if (screen52.getCurrentPos() == 82) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1825 Log.d(TAG, "STRPCCMD got a -128 command at " + screen52.getCurrentPos());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1826 StringBuffer value = new StringBuffer();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1827 int b;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1828 char c;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1829 int[] pco = new int[9];
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1830 int[] pcoOk = {0xfc, 0xd7, 0xc3, 0xd6, 0x40, 0x83, 0x80, 0xa1, 0x80};
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1831
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1832 for (int i = 0; i < 9; i++) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1833 b = bk.getNextByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1834 pco[i] = ((b & 0xff));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1835 c = codePage.ebcdic2uni(b);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1836 value.append(c);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1837 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1838
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1839 // Check "PCO-String"
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1840 if (Arrays.equals(pco, pcoOk)) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1841 strpccmd = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1842 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1843
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1844 // we return in the stream to have all chars
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1845 // arrive at the screen for later processing
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1846 for (int i = 0; i < 9; i++)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1847 bk.setPrevByte();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1848
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1849 //}
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1850 // no break: so every chars arrives
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1851 // on the screen for later parsing
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1852 //break;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1853
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1854 default: // all others must be output to screen
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1855 byte byte0 = bk.getByteOffset(-1);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1856
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1857 if (isAttribute(byte0)) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1858 screen52.setAttr(byte0);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1859 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1860 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1861 if (!screen52.isStatusErrorCode()) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1862 if (!isDataEBCDIC(byte0)) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1863 // if (byte0 == 255) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1864 // sendNegResponse(NR_REQUEST_ERROR,0x05,0x01,0x42,
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1865 // " Attempt to send FF to screen");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1866 // }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1867 // else
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1868 screen52.setChar(byte0);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1869 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1870 else
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1871 //LDC - 13/02/2003 - Convert it to unicode
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1872 //screen52.setChar(getASCIIChar(byte0));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1873 screen52.setChar(codePage.ebcdic2uni(byte0));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1874 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1875 else {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1876 if (byte0 == 0)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1877 screen52.setChar(byte0);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1878 else
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1879 //LDC - 13/02/2003 - Convert it to unicode
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1880 //screen52.setChar(getASCIIChar(byte0));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1881 screen52.setChar(codePage.ebcdic2uni(byte0));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1882 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1883 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1884
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1885 break;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1886 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1887
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1888 if (error)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1889 done = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1890 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1891 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1892 catch (Exception e) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1893 Log.w(TAG, "write to display " + e.getMessage());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1894 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1895
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1896 ;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1897
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1898 processCC1(control1);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1899
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1900 return error;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1901 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1902
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1903 private boolean processSOH() throws Exception {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1904 int l = bk.getNextByte(); // length
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1905 Log.d(TAG, " byte 0 " + l);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1906
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1907 if (l > 0 && l <= 7) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1908 bk.getNextByte(); // flag byte 2
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1909 bk.getNextByte(); // reserved
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1910 bk.getNextByte(); // resequence fields
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1911 screen52.clearTable();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1912
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1913 // well that is the first time I have seen this. This fixes a
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1914 // problem with S/36 command line. Finally got it.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1915 if (l <= 3) return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1916
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1917 screen52.setErrorLine(bk.getNextByte()); // error row
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1918 int byte1 = 0;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1919
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1920 if (l >= 5) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1921 byte1 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1922 dataIncluded[23] = (byte1 & 0x80) == 0x80;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1923 dataIncluded[22] = (byte1 & 0x40) == 0x40;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1924 dataIncluded[21] = (byte1 & 0x20) == 0x20;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1925 dataIncluded[20] = (byte1 & 0x10) == 0x10;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1926 dataIncluded[19] = (byte1 & 0x8) == 0x8;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1927 dataIncluded[18] = (byte1 & 0x4) == 0x4;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1928 dataIncluded[17] = (byte1 & 0x2) == 0x2;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1929 dataIncluded[16] = (byte1 & 0x1) == 0x1;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1930 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1931
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1932 if (l >= 6) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1933 byte1 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1934 dataIncluded[15] = (byte1 & 0x80) == 0x80;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1935 dataIncluded[14] = (byte1 & 0x40) == 0x40;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1936 dataIncluded[13] = (byte1 & 0x20) == 0x20;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1937 dataIncluded[12] = (byte1 & 0x10) == 0x10;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1938 dataIncluded[11] = (byte1 & 0x8) == 0x8;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1939 dataIncluded[10] = (byte1 & 0x4) == 0x4;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1940 dataIncluded[9] = (byte1 & 0x2) == 0x2;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1941 dataIncluded[8] = (byte1 & 0x1) == 0x1;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1942 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1943
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1944 if (l >= 7) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1945 byte1 = bk.getNextByte();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1946 dataIncluded[7] = (byte1 & 0x80) == 0x80;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1947 dataIncluded[6] = (byte1 & 0x40) == 0x40;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1948 dataIncluded[5] = (byte1 & 0x20) == 0x20;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1949 dataIncluded[4] = (byte1 & 0x10) == 0x10;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1950 dataIncluded[3] = (byte1 & 0x8) == 0x8;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1951 dataIncluded[2] = (byte1 & 0x4) == 0x4;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1952 dataIncluded[1] = (byte1 & 0x2) == 0x2;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1953 dataIncluded[0] = (byte1 & 0x1) == 0x1;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1954 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1955
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1956 return false;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1957 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1958 else {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1959 sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x2B,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1960 "invalid SOH length");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1961 return true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1962 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1963 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1964
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1965 private void processCC0(byte byte0) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1966 Log.d(TAG, " Control byte0 " + Integer.toBinaryString(byte0 & 0xff));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1967 boolean lockKeyboard = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1968 boolean resetMDT = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1969 boolean resetMDTAll = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1970 boolean nullMDT = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1971 boolean nullAll = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1972
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1973 // Bits 3 to 6 are reserved and should be set to '0000'
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1974 // 0xE0 = '11100000' - only the first 3 bits are tested
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1975 if ((byte0 & 0xE0) == 0x00) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1976 lockKeyboard = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1977 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1978
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1979 // '00100000' = 0x20 /32 -- just lock keyboard
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1980 // '01000000' = 0x40 /64
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1981 // '01100000' = 0x60 /96
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1982 // '10000000' = 0x80 /128
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1983 // '10100000' = 0xA0 /160
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1984 // '11000000' = 0xC0 /192
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1985 // '11100000' = 0xE0 /224
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1986
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
1987 switch (byte0 & 0xE0) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1988 case 0x40:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1989 resetMDT = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1990 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1991
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1992 case 0x60:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1993 resetMDTAll = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1994 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1995
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1996 case 0x80:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1997 nullMDT = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1998 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
1999
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2000 case 0xA0:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2001 resetMDT = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2002 nullAll = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2003 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2004
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2005 case 0xC0:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2006 resetMDT = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2007 nullMDT = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2008 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2009
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2010 case 0xE0:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2011 resetMDTAll = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2012 nullAll = true;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2013 break;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2014 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2015
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2016 if (lockKeyboard) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2017 screen52.getOIA().setKeyBoardLocked(true);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2018 pendingUnlock = false;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2019 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2020 else
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2021 pendingUnlock = false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2022
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2023 if (resetMDT || resetMDTAll || nullMDT || nullAll) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2024 int f = screen52.getScreenFields().getSize();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2025
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2026 for (int x = 0; x < f; x++) {
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
2027 ScreenField sf = screen52.getScreenFields().getField(x);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2028 if (!sf.isBypassField()) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2029 if ((nullMDT && sf.mdt) || nullAll) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2030 sf.setFieldChar((char) 0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2031 screen52.drawField(sf);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2032 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2033 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2034
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2035 if (resetMDTAll || (resetMDT && !sf.isBypassField()))
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2036 sf.resetMDT();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2037 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2038 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2039 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2040
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2041 private void processCC1(byte byte1) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2042 Log.d(TAG, " Control byte1 " + Integer.toBinaryString(byte1 & 0xff));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2043
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2044 if ((byte1 & 0x04) == 0x04) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2045 manager.playBeep();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2046 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2047
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2048 if ((byte1 & 0x02) == 0x02) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2049 screen52.getOIA().setMessageLightOff();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2050 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2051
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2052 if ((byte1 & 0x01) == 0x01) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2053 screen52.getOIA().setMessageLightOn();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2054 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2055
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2056 if ((byte1 & 0x01) == 0x01 && (byte1 & 0x02) == 0x02) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2057 screen52.getOIA().setMessageLightOn();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2058 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2059
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2060 // reset blinking cursor seems to control whether to set or not set the
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2061 // the cursor position. No documentation for this just testing and
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2062 // looking at the bit settings of this field. This was a pain in the
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2063 // ass!
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2064 //
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2065 // if it is off '0' then keep existing cursor positioning information
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2066 // if it is on '1' then reset the cursor positioning information
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2067 // *** Note *** unless we receive bit 4 on at the same time
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2068 // this seems to work so far
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2069 if ((byte1 & 0x20) == 0x20 && (byte1 & 0x08) == 0x00) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2070 screen52.setPendingInsert(false);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2071 Log.d(TAG, " WTD position no move");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2072 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2073 else {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2074 screen52.setPendingInsert(true);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2075 Log.d(TAG, " WTD position move to home" + screen52.homePos + " row "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2076 + screen52.getRow(screen52.homePos) + " col "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2077 + screen52.getCol(screen52.homePos));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2078 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2079
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2080 // in enhanced mode we sometimes only receive bit 6 turned on which
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2081 // is reset blinking cursor
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2082 if ((byte1 & 0x20) == 0x20 && enhanced) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2083 cursorOn = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2084 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2085
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2086 if (!screen52.isStatusErrorCode() && (byte1 & 0x08) == 0x08) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2087 // screen52.setStatus(screen52.STATUS_SYSTEM,screen52.STATUS_VALUE_OFF,null);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2088 cursorOn = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2089 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2090
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2091 if ((byte1 & 0x20) == 0x20 && (byte1 & 0x08) == 0x00) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2092 screen52.setPendingInsert(false, 1, 1);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2093 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2094 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2095
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2096 private boolean isAttribute(int byte0) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2097 int byte1 = byte0 & 0xff;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2098 return (byte1 & 0xe0) == 0x20;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2099 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2100
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2101 //LDC - 12/02/2003 - Function name changed from isData to isDataEBCDIC
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2102 private boolean isDataEBCDIC(int byte0) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2103 int byte1 = byte0 & 0xff;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2104
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2105 // here it should always be less than 255
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2106 if (byte1 >= 64 && byte1 < 255)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2107 return true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2108 else
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2109 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2110 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2111
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2112 //LDC - 12/02/2003 - Test if the unicode character is a displayable
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2113 // character.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2114 // The first 32 characters are non displayable characters
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2115 // This is normally the inverse of isDataEBCDIC (That's why there is a
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2116 // check on 255 -> 0xFFFF
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
2117 private boolean isDataUnicode(int data) {
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
2118 return (((data < 0) || (data >= 32)) && (data != 0xFFFF));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2119 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2120
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2121 private void writeStructuredField() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2122 boolean done = false;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2123
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2124 try {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2125 int length = ((bk.getNextByte() & 0xff) << 8 | (bk.getNextByte() & 0xff));
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2126
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2127 while (bk.hasNext() && !done) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2128 switch (bk.getNextByte()) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2129 case -39: // SOH - Start of Header Order
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2130 switch (bk.getNextByte()) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2131 case 112: // 5250 Query
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2132 bk.getNextByte(); // get null required field
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2133 sendQueryResponse();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2134 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2135
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2136 default:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2137 Log.d(TAG, "invalid structured field sub command "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2138 + bk.getByteOffset(-1));
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2139 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2140 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2141
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2142 break;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2143
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2144 default:
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2145 Log.d(TAG, "invalid structured field command "
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2146 + bk.getByteOffset(-1));
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2147 break;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2148 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2149 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2150 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2151 catch (Exception e) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2152 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2153
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2154 ;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2155 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2156
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2157 private final void writeErrorCode() throws Exception {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2158 screen52.setCursor(screen52.getErrorLine(), 1); // Skip the control byte
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2159 screen52.setStatus(Screen5250.STATUS_ERROR_CODE,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2160 Screen5250.STATUS_VALUE_ON, null);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2161 screen52.saveErrorLine();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2162 cursorOn = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2163 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2164
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2165 private final void writeErrorCodeToWindow() throws Exception {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2166 int fromCol = bk.getNextByte() & 0xff; // from column
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2167 int toCol = bk.getNextByte() & 0xff; // to column
216
cd07c1648016 test buffer changed when 5250 keyboard unlocks
Carl Byington <carl@five-ten-sg.com>
parents: 215
diff changeset
2168 screen52.setCursor(screen52.getErrorLine(), fromCol); // Skip the control byte
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2169 screen52.setStatus(Screen5250.STATUS_ERROR_CODE,
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2170 Screen5250.STATUS_VALUE_ON, null);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2171 screen52.saveErrorLine();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2172 cursorOn = true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2173 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2174
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2175 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2176 * Method sendQueryResponse
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2177 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2178 * The query command is used to obtain information about the capabilities of
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2179 * the 5250 display.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2180 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2181 * The Query command must follow an Escape (0x04) and Write Structured Field
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2182 * command (0xF3).
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2183 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2184 * This section is modeled after the rfc1205 - 5250 Telnet Interface section
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2185 * 5.3
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2186 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2187 * @throws IOException
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2188 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2189 private final void sendQueryResponse() throws IOException {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2190 Log.i(TAG, "sending query response");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2191 byte abyte0[] = new byte[64];
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2192 abyte0[0] = 0; // Cursor Row/column (set to zero)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2193 abyte0[1] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2194 abyte0[2] = -120; // X'88' inbound write structure Field aid
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2195
257
8a6c7c7ffe0d support 132 column mode
Carl Byington <carl@five-ten-sg.com>
parents: 219
diff changeset
2196 if (enhanced) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2197 abyte0[3] = 0; // 0x003D (61) length of query response
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2198 abyte0[4] = 64; // "" see note below ?????????
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2199 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2200 else {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2201 abyte0[3] = 0; // 0x003A (58) length of query response
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2202 abyte0[4] = 58; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2203 // the length between 58 and 64 seems to cause
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2204 // different formatting codes to be sent from
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2205 // the host ???????????????? why ???????
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2206 // Well the why can be found in the manual if
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2207 // read a little more ;-)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2208 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2209
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2210 abyte0[5] = -39; // command class 0xD9
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2211 abyte0[6] = 112; // Command type query 0x70
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2212 abyte0[7] = -128; // 0x80 Flag byte
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2213 abyte0[8] = 6; // Controller Hardware Class
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2214 abyte0[9] = 0; // 0x0600 - Other WSF or another 5250 Emulator
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2215 abyte0[10] = 1; // Controller Code Level
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2216 abyte0[11] = 1; // Version 1 Rel 1.0
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2217 abyte0[12] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2218 abyte0[13] = 0; // 13 - 28 are reserved so set to 0x00
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2219 abyte0[14] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2220 abyte0[15] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2221 abyte0[16] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2222 abyte0[17] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2223 abyte0[18] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2224 abyte0[19] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2225 abyte0[20] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2226 abyte0[21] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2227 abyte0[22] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2228 abyte0[23] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2229 abyte0[24] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2230 abyte0[25] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2231 abyte0[26] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2232 abyte0[27] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2233 abyte0[28] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2234 abyte0[29] = 1; // Device type - 0x01 5250 Emulator
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2235 abyte0[30] = codePage.uni2ebcdic('5'); // Device type character
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2236 abyte0[31] = codePage.uni2ebcdic('2'); // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2237 abyte0[32] = codePage.uni2ebcdic('5'); // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2238 abyte0[33] = codePage.uni2ebcdic('1'); // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2239 abyte0[34] = codePage.uni2ebcdic('0'); // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2240 abyte0[35] = codePage.uni2ebcdic('1'); // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2241 abyte0[36] = codePage.uni2ebcdic('1'); // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2242 abyte0[37] = 2; // Keyboard Id - 0x02 Standard Keyboard
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2243 abyte0[38] = 0; // extended keyboard id
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2244 abyte0[39] = 0; // reserved
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2245 abyte0[40] = 0; // 40 - 43 Display Serial Number
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2246 abyte0[41] = 36; //
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2247 abyte0[42] = 36; //
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2248 abyte0[43] = 0; //
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2249 abyte0[44] = 1; // Maximum number of display fields - 256
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2250 abyte0[45] = 0; // 0x0100
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2251 abyte0[46] = 0; // 46 -48 Reserved set to 0x00
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2252 abyte0[47] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2253 abyte0[48] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2254 abyte0[49] = 1; // 49 - 53 Controller Display Capability
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2255 abyte0[50] = 17; // see rfc - tired of typing :-)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2256 abyte0[51] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2257 abyte0[52] = 0; // ""
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2258
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2259 // 53
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2260 // Bit 0-2: B'000' - no graphics capability
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2261 // B'001' - 5292-2 style graphics
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2262 // Bit 3-7: B '00000' = reserved (it seems for Client access)
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2263
257
8a6c7c7ffe0d support 132 column mode
Carl Byington <carl@five-ten-sg.com>
parents: 219
diff changeset
2264 if (enhanced) {
8a6c7c7ffe0d support 132 column mode
Carl Byington <carl@five-ten-sg.com>
parents: 219
diff changeset
2265 // abyte0[53] = 0x5E; // 0x5E turns on enhanced mode
8a6c7c7ffe0d support 132 column mode
Carl Byington <carl@five-ten-sg.com>
parents: 219
diff changeset
2266 // abyte0[53] = 0x27; // 0x5E turns on enhanced mode
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2267 abyte0[53] = 0x7; // 0x5E turns on ehnhanced mode
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2268 Log.i(TAG, "enhanced options");
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2269 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2270 else
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2271 abyte0[53] = 0x0; // 0x0 is normal emulation
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2272
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2273 abyte0[54] = 24; // 54 - 60 Reserved set to 0x00
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2274 // 54 - I found out is used for enhanced user
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2275 // interface level 3. Bit 4 allows headers
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2276 // and footers for windows
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2277 abyte0[54] = 8; // 54 - 60 Reserved set to 0x00
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2278 // 54 - I found out is used for enhanced user
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2279 // interface level 3. Bit 4 allows headers
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2280 // and footers for windows
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2281 abyte0[55] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2282 abyte0[56] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2283 abyte0[57] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2284 abyte0[58] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2285 abyte0[59] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2286 abyte0[60] = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2287 abyte0[61] = 0; // gridlines are not supported
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2288 abyte0[62] = 0; // gridlines are not supported
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2289 abyte0[63] = 0;
414
12b2a3a35afe more debugging looking for duplicate transmission
Carl Byington <carl@five-ten-sg.com>
parents: 413
diff changeset
2290 Log.i(TAG, "sendQueryResponse() writeGDS()");
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2291 writeGDS(0, 0, abyte0); // now tell them about us
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2292 abyte0 = null;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2293 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2294
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2295 protected final boolean negotiate(byte abyte0[]) throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2296 int i = 0;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2297
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2298 // from server negotiations
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2299 if (abyte0[i] == IAC) { // -1
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2300 while (i < abyte0.length && abyte0[i++] == -1)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2301
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2302 // while(i < abyte0.length && (abyte0[i] == -1 || abyte0[i++] == 0x20))
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2303 switch (abyte0[i++]) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2304 // we will not worry about what it WONT do
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2305 case WONT: // -4
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2306 default:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2307 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2308
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2309 case DO: //-3
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2310
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2311 // not sure why but since moving to V5R2 we are receiving a
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2312 // DO with no option when connecting a second session with
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2313 // device name. Can not find the cause at all. If anybody
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2314 // is interested please debug this until then this works.
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2315 if (i < abyte0.length) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2316 switch (abyte0[i]) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2317 case TERMINAL_TYPE: // 24
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2318 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2319 baosp.write(WILL);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2320 baosp.write(TERMINAL_TYPE);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2321 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2322 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2323 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2324
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2325 case OPT_END_OF_RECORD: // 25
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2326 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2327 baosp.write(WILL);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2328 baosp.write(OPT_END_OF_RECORD);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2329 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2330 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2331 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2332
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2333 case TRANSMIT_BINARY: // 0
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2334 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2335 baosp.write(WILL);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2336 baosp.write(TRANSMIT_BINARY);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2337 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2338 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2339 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2340
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2341 case TIMING_MARK: // 6 rfc860
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
2342 Log.d(TAG, "Timing Mark Received and notifying the server that we will not do it.");
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2343 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2344 baosp.write(WONT);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2345 baosp.write(TIMING_MARK);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2346 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2347 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2348 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2349
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2350 case NEW_ENVIRONMENT: // 39 rfc1572, rfc4777
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2351 // allways send new environment vars ...
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2352 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2353 baosp.write(WILL);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2354 baosp.write(NEW_ENVIRONMENT);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2355 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2356 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2357 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2358
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2359 default: // every thing else we will not do at this time
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2360 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2361 baosp.write(WONT);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2362 baosp.write(abyte0[i]); // either
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2363 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2364 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2365 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2366 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2367 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2368
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2369 i++;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2370 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2371
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2372 case WILL:
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2373 switch (abyte0[i]) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2374 case OPT_END_OF_RECORD: // 25
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2375 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2376 baosp.write(DO);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2377 baosp.write(OPT_END_OF_RECORD);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2378 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2379 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2380 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2381
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2382 case TRANSMIT_BINARY: // '\0'
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2383 baosp.write(IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2384 baosp.write(DO);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2385 baosp.write(TRANSMIT_BINARY);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2386 writeByte(baosp.toByteArray());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2387 baosp.reset();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2388 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2389 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2390
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2391 i++;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2392 break;
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2393
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2394 case SB: // -6
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2395 if (abyte0[i] == NEW_ENVIRONMENT && abyte0[i + 1] == 1) {
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2396 negNewEnvironment();
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2397
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2398 while (++i < abyte0.length && abyte0[i + 1] != IAC);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2399 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2400
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2401 if (abyte0[i] == TERMINAL_TYPE && abyte0[i + 1] == 1) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2402 baosp.write(IAC);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2403 baosp.write(SB);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2404 baosp.write(TERMINAL_TYPE);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2405 baosp.write(QUAL_IS);
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2406
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2407 if (!support132)
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2408 baosp.write("IBM-3179-2".getBytes());
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2409 else
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2410 baosp.write("IBM-3477-FC".getBytes());
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2411
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2412 baosp.write(IAC);
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2413 baosp.write(SE);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2414 writeByte(baosp.toByteArray());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2415 baosp.reset();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2416 i++;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2417 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2418
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2419 i++;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2420 break;
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2421 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2422
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2423 return true;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2424 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2425 else {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2426 return false;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2427 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2428 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2429
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2430 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2431 * Negotiate new environment string for device name
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2432 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2433 * @throws IOException
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2434 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2435 private void negNewEnvironment() throws IOException {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2436 baosp.write(IAC);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2437 baosp.write(SB);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2438 baosp.write(NEW_ENVIRONMENT);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2439 baosp.write(IS);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2440
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2441 // http://tools.ietf.org/html/rfc4777
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2442
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2443 if (kbdTypesCodePage != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2444 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2445 baosp.write("KBDTYPE".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2446 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2447 baosp.write(kbdTypesCodePage.kbdType.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2448 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2449 baosp.write("CODEPAGE".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2450 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2451 baosp.write(kbdTypesCodePage.codepage.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2452 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2453 baosp.write("CHARSET".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2454 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2455 baosp.write(kbdTypesCodePage.charset.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2456 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2457
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2458 if (devName != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2459 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2460 baosp.write("DEVNAME".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2461 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2462 baosp.write(negDeviceName().getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2463 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2464
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2465 if (user != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2466 baosp.write(VAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2467 baosp.write("USER".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2468 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2469 baosp.write(user.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2470
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2471 if (password != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2472 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2473 baosp.write("IBMRSEED".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2474 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2475 baosp.write(NEGOTIATE_ESC);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2476 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2477 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2478 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2479 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2480 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2481 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2482 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2483 baosp.write(0x0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2484 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2485 baosp.write("IBMSUBSPW".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2486 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2487 baosp.write(password.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2488 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2489
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2490 if (library != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2491 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2492 baosp.write("IBMCURLIB".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2493 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2494 baosp.write(library.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2495 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2496
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2497 if (initialMenu != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2498 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2499 baosp.write("IBMIMENU".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2500 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2501 baosp.write(initialMenu.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2502 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2503
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2504 if (program != null) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2505 baosp.write(USERVAR);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2506 baosp.write("IBMPROGRAM".getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2507 baosp.write(VALUE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2508 baosp.write(program.getBytes());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2509 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2510 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2511
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2512 baosp.write(IAC);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2513 baosp.write(SE);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2514 writeByte(baosp.toByteArray());
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2515 baosp.reset();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2516 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2517
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2518 /**
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2519 * This will negotiate a device name with controller. if the sequence is
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2520 * less than zero then it will send the device name as specified. On each
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2521 * unsuccessful attempt a sequential number is appended until we find one or
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2522 * the controller says no way.
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2523 *
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2524 * @return String
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2525 */
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2526 private String negDeviceName() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2527 if (devSeq++ == -1) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2528 devNameUsed = devName;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2529 return devName;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2530 }
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2531 else {
445
8fa8e73e2f5c update to tn5250j version 0.7.7, svn r1270
Carl Byington <carl@five-ten-sg.com>
parents: 438
diff changeset
2532 StringBuilder sb = new StringBuilder(devName + devSeq);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2533 int ei = 1;
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2534
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2535 while (sb.length() > 10) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2536 sb.setLength(0);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2537 sb.append(devName.substring(0, devName.length() - ei++));
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2538 sb.append(devSeq);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2539 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2540
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2541 devNameUsed = sb.toString();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2542 return devNameUsed;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2543 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2544 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2545
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2546 public final void setCodePage(String cp) {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2547 codePage = CharMappings.getCodePage(cp);
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2548 cp = cp.toLowerCase();
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2549
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2550 for (KbdTypesCodePages kbdtyp : KbdTypesCodePages.values()) {
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2551 if (("cp" + kbdtyp.codepage).equals(cp) || kbdtyp.ccsid.equals(cp)) {
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2552 kbdTypesCodePage = kbdtyp;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2553 break;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2554 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2555 }
112
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2556
77ac18bc1b2f cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents: 103
diff changeset
2557 Log.i(TAG, "Chose keyboard mapping " + kbdTypesCodePage.toString() + " for code page " + cp);
25
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2558 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2559
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2560 public final ICodePage getCodePage() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2561 return codePage;
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2562 }
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2563
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2564 public void signalBell() {
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2565 manager.playBeep();
5949eb469a79 adding tn5250 files, native android logging
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
2566 }
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2567
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2568 }