comparison src/com/five_ten_sg/connectbot/transport/AbsTransport.java @ 42:7ac846a07ed4 tn5250

start tn5250 integration
author Carl Byington <carl@five-ten-sg.com>
date Wed, 11 Jun 2014 09:14:31 -0700
parents 139394237973
children 6b0f1ece1d91
comparison
equal deleted inserted replaced
41:9621ac4dd5eb 42:7ac846a07ed4
39 TerminalBridge bridge; 39 TerminalBridge bridge;
40 HostBean host; 40 HostBean host;
41 vt320 buffer; 41 vt320 buffer;
42 String emulation; 42 String emulation;
43 43
44 class vt320Default extends vt320 {
45 @Override
46 public void debug(String s) {
47 Log.d(TAG, s);
48 }
49 @Override
50 public void write(byte[] b) {
51 try {
52 if (b != null && transport != null)
53 if (bridge.monitor != null) bridge.monitor.hostData(b);
54
55 transport.write(b);
56 }
57 catch (IOException e) {
58 Log.e(TAG, "Problem writing outgoing data in vt320() thread", e);
59 }
60 }
61 @Override
62 public void write(int b) {
63 try {
64 if (transport != null)
65 if (bridge.monitor != null) bridge.monitor.hostData(b);
66
67 transport.write(b);
68 }
69 catch (IOException e) {
70 Log.e(TAG, "Problem writing outgoing data in vt320() thread", e);
71 }
72 }
73 // We don't use telnet sequences.
74 @Override
75 public void sendTelnetCommand(byte cmd) {
76 }
77 // We don't want remote to resize our window.
78 @Override
79 public void setWindowSize(int c, int r) {
80 }
81 // test for changed screen contents
82 @Override
83 public void testChanged() {
84 if (bridge.monitor != null) bridge.monitor.testChanged();
85 }
86 // play beep noise
87 @Override
88 public void beep() {
89 if (bridge.parent.isShown())
90 manager.playBeep();
91 else
92 manager.sendActivityNotification(host);
93 }
94 // bridge.monitor placement of new characters
95 @Override
96 public void putChar(int c, int l, char ch, int attributes) {
97 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c);
98
99 super.putChar(c, l, ch, attributes);
100 }
101 @Override
102 public void insertChar(int c, int l, char ch, int attributes) {
103 if (bridge.monitor != null) bridge.monitor.screenChanged(l, l, c, width - 1);
104
105 super.insertChar(c, l, ch, attributes);
106 }
107 @Override
108 public void insertLine(int l, int n, boolean scrollDown) {
109 if (bridge.monitor != null) {
110 if (scrollDown) bridge.monitor.screenChanged(l, height - 1, 0, width - 1);
111 else bridge.monitor.screenChanged(0, l, 0, width - 1);
112 }
113
114 super.insertLine(l, n, scrollDown);
115 }
116 @Override
117 public void deleteLine(int l) {
118 if (bridge.monitor != null) bridge.monitor.screenChanged(l, height - 1, 0, width - 1);
119
120 super.deleteLine(l);
121 }
122 @Override
123 public void deleteChar(int c, int l) {
124 if (bridge.monitor != null) bridge.monitor.screenChanged(l, l, c, width - 1);
125
126 super.deleteChar(c, l);
127 }
128 @Override
129 public void setCursorPosition(int c, int l) {
130 if (bridge.monitor != null) bridge.monitor.cursorMove(l, c);
131
132 super.setCursorPosition(c, l);
133 }
134 };
135
136
44 public AbsTransport() {} 137 public AbsTransport() {}
45 138
46 /** 139 /**
47 * @return protocol part of the URI 140 * @return protocol part of the URI
48 */ 141 */
142 235
143 public String getEmulation() { 236 public String getEmulation() {
144 return emulation; 237 return emulation;
145 } 238 }
146 239
147 public void setLinks(TerminalManager manager, TerminalBridge bridge, HostBean host, vt320 buffer, String emulation) { 240 public vt320 getTransportbuffer() {
241 buffer = vt320Default();
242 int scrollback = (host.getWantSession()) ? manager.getScrollback() : 0;
243 buffer.setBufferSize(scrollback);
244 buffer.setDisplay(bridge);
245 return buffer;
246 }
247
248 public void setLinks(TerminalManager manager, TerminalBridge bridge, HostBean host, String emulation) {
148 this.manager = manager; 249 this.manager = manager;
149 this.bridge = bridge; 250 this.bridge = bridge;
150 this.host = host; 251 this.host = host;
151 this.buffer = buffer;
152 this.emulation = emulation; 252 this.emulation = emulation;
153 } 253 }
154 254
155 /** 255 /**
156 * Whether or not this transport type can forward ports. 256 * Whether or not this transport type can forward ports.
286 386
287 /** 387 /**
288 * @return a key listener 388 * @return a key listener
289 */ 389 */
290 public TerminalKeyListener getTerminalKeyListener() { 390 public TerminalKeyListener getTerminalKeyListener() {
291 return new TerminalKeyListener(manager, bridge, buffer, host.getEncoding()); 391 return new TerminalKeyListener(manager, bridge, buffer, host.getEncoding());
292 } 392 }
293 393
294 } 394 }