annotate src/org/tn5250j/framework/tn5250/tnvt.java @ 25:5949eb469a79 tn5250

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