annotate src/com/five_ten_sg/connectbot/transport/TN5250.java @ 13:b39bcf616a6f tn5250

adding tn5250 files
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 18:56:41 -0700
parents 6aaefb22d876
children cfcb8d9859a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /*
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 * 510ConnectBot
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 * Copyright 2014 Carl Byington
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 * Licensed under the Apache License, Version 2.0 (the "License");
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 * you may not use this file except in compliance with the License.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 * You may obtain a copy of the License at
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 * http://www.apache.org/licenses/LICENSE-2.0
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 * Unless required by applicable law or agreed to in writing, software
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 * distributed under the License is distributed on an "AS IS" BASIS,
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 * See the License for the specific language governing permissions and
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 * limitations under the License.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 package com.five_ten_sg.connectbot.transport;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 import java.io.IOException;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 import java.io.InputStream;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 import java.io.OutputStream;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 import java.net.Socket;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 import java.net.SocketException;
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
25 import java.net.UnknownHostException;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 import java.util.List;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 import java.util.Map;
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
28 import java.util.regex.Matcher;
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
29 import java.util.regex.Pattern;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30
12
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
31 import org.tn5250j.framework.tn5250.Screen5250;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
32 import org.tn5250j.framework.tn5250.tnvt;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
33
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
34 import com.five_ten_sg.connectbot.R;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 import com.five_ten_sg.connectbot.bean.HostBean;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 import com.five_ten_sg.connectbot.bean.PortForwardBean;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 import com.five_ten_sg.connectbot.service.TerminalBridge;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 import com.five_ten_sg.connectbot.service.TerminalManager;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 import com.five_ten_sg.connectbot.util.HostDatabase;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 import android.content.Context;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42 import android.net.Uri;
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
43 import android.util.Log;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 * @author Carl Byington
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 *
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 public class TN5250 extends AbsTransport {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 private static final String PROTOCOL = "tn5250";
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
52 private static final String TAG = "ConnectBot.tn5250";
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
53 private static final int DEFAULT_PORT = 23;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
54 private Screen5250 screen52;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
55
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
56 private tnvt handler = null;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
57 private Socket socket;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
58
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59 private InputStream is;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60 private OutputStream os;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
61 private int width;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 private int height;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64 private boolean connected = false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65
12
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
66 static final Pattern hostmask;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
67 static {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
68 hostmask = Pattern.compile("^([0-9a-z.-]+)(:(\\d+))?$", Pattern.CASE_INSENSITIVE);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
69 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
70
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
71
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72 public TN5250() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73 super();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76 public TN5250(HostBean host, TerminalBridge bridge, TerminalManager manager) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77 super(host, bridge, manager);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 handler = new tnvt(screen52, true, false, bridge, manager);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
79 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
80
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
81
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 * @return protocol part of the URI
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
85 public static String getProtocolName() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
86 return PROTOCOL;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
87 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
88
12
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
89 public Uri getUri(String input) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
90 Matcher matcher = hostmask.matcher(input);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
91
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
92 if (!matcher.matches())
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
93 return null;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
94
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
95 StringBuilder sb = new StringBuilder();
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
96 sb.append(PROTOCOL)
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
97 .append("://")
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
98 .append(matcher.group(1));
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
99 String portString = matcher.group(3);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
100 int port = DEFAULT_PORT;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
101
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
102 if (portString != null) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
103 try {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
104 port = Integer.parseInt(portString);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
105
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
106 if (port < 1 || port > 65535) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
107 port = DEFAULT_PORT;
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
108 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
109 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
110 catch (NumberFormatException nfe) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
111 // Keep the default port
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
112 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
113 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
114
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
115 if (port != DEFAULT_PORT) {
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
116 sb.append(':');
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
117 sb.append(port);
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
118 }
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
119
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
120 sb.append("/#")
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
121 .append(Uri.encode(input));
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
122 Uri uri = Uri.parse(sb.toString());
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
123 return uri;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
124 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
125
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
126 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
127 * Causes transport to connect to the target host. After connecting but before a
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
128 * session is started, must call back to {@link TerminalBridge#onConnected()}.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
129 * After that call a session may be opened.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
130 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
131 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
132 public void connect() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
133 try {
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
134 connected = handler.connect(host.getHostname(), host.getPort());
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
135 is = handler.bin;
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
136 os = handler.bout;
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
137 bridge.onConnected();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
138 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
139 catch (UnknownHostException e) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
140 Log.d(TAG, "IO Exception connecting to host", e);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
141 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
142 catch (IOException e) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
143 Log.d(TAG, "IO Exception connecting to host", e);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
144 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
145 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
146
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
147
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
148 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
149 * Checks if read() will block. If there are no bytes remaining in
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
150 * the underlying transport, return true.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
151 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
152 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
153 public boolean willBlock() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
154 if (is == null) return true;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
155 try {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
156 return is.available() == 0;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
157 } catch (Exception e) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
158 return true;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
159 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
160 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
161
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
162 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
163 * Reads from the transport. Transport must support reading into a byte array
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
164 * <code>buffer</code> at the start of <code>offset</code> and a maximum of
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
165 * <code>length</code> bytes. If the remote host disconnects, throw an
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
166 * {@link IOException}.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
167 * @param buffer byte buffer to store read bytes into
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
168 * @param offset where to start writing in the buffer
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
169 * @param length maximum number of bytes to read
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
170 * @return number of bytes read
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
171 * @throws IOException when remote host disconnects
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
172 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
173 public int read(byte[] buffer, int offset, int length) throws IOException {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
174 return 0;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
175 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
176
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
177
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
178 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
179 * Writes to the transport. If the host is not yet connected, simply return without
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
180 * doing anything. An {@link IOException} should be thrown if there is an error after
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
181 * connection.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
182 * @param buffer bytes to write to transport
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
183 * @throws IOException when there is a problem writing after connection
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
184 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
185 public void write(byte[] buffer) throws IOException {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
186 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
187
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
188 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
189 * Writes to the transport. See {@link #write(byte[])} for behavior details.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
190 * @param c character to write to the transport
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
191 * @throws IOException when there is a problem writing after connection
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
192 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
193 public void write(int c) throws IOException {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
194 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
195
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
196 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
197 * Flushes the write commands to the transport.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
198 * @throws IOException when there is a problem writing after connection
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
199 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
200 public void flush() throws IOException {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
201 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
202
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
203 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
204 * Closes the connection to the terminal. Note that the resulting failure to read
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
205 * should call {@link TerminalBridge#dispatchDisconnect(boolean)}.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
206 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
207 public void close() {
13
b39bcf616a6f adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 12
diff changeset
208 handler.disconnect();
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
209 connected = false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
210 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
211
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
212 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
213 * Tells the transport what dimensions the display is currently
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
214 * @param columns columns of text
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
215 * @param rows rows of text
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
216 * @param width width in pixels
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
217 * @param height height in pixels
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
218 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
219 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
220 public void setDimensions(int columns, int rows, int width, int height) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
221 // do nothing
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
222 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
223
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
224 public void setOptions(Map<String, String> options) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
225 // do nothing
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
226 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
227
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
228 public Map<String, String> getOptions() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
229 return null;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
230 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
231
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
232 public void setCompression(boolean compression) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
233 // do nothing
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
234 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
235
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
236 public void setHttpproxy(String httpproxy) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
237 // do nothing
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
238 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
239
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
240 public void setUseAuthAgent(String useAuthAgent) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
241 // do nothing
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
242 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
243
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
244 public void setEmulation(String emulation) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
245 this.emulation = emulation;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
246 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
247
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
248 public String getEmulation() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
249 return emulation;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
250 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
251
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
252 public void setHost(HostBean host) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
253 this.host = host;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
254 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
255
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
256 public void setBridge(TerminalBridge bridge) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
257 this.bridge = bridge;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
258 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
259
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
260 public void setManager(TerminalManager manager) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
261 this.manager = manager;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
262 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
263
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
264 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
265 * Whether or not this transport type can forward ports.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
266 * @return true on ability to forward ports
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
267 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
268 public boolean canForwardPorts() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
269 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
270 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
271
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
272 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
273 * Adds the {@link PortForwardBean} to the list.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
274 * @param portForward the port forward bean to add
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
275 * @return true on successful addition
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
276 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
277 public boolean addPortForward(PortForwardBean portForward) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
278 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
279 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
280
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
281 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
282 * Enables a port forward member. After calling this method, the port forward should
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
283 * be operational iff it could be enabled by the transport.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
284 * @param portForward member of our current port forwards list to enable
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
285 * @return true on successful port forward setup
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
286 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
287 public boolean enablePortForward(PortForwardBean portForward) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
288 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
289 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
290
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
291 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
292 * Disables a port forward member. After calling this method, the port forward should
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
293 * be non-functioning iff it could be disabled by the transport.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
294 * @param portForward member of our current port forwards list to enable
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
295 * @return true on successful port forward tear-down
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
296 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
297 public boolean disablePortForward(PortForwardBean portForward) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
298 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
299 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
300
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
301 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
302 * Removes the {@link PortForwardBean} from the available port forwards.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
303 * @param portForward the port forward bean to remove
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
304 * @return true on successful removal
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
305 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
306 public boolean removePortForward(PortForwardBean portForward) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
307 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
308 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
309
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
310 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
311 * Gets a list of the {@link PortForwardBean} currently used by this transport.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
312 * @return the list of port forwards
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
313 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
314 public List<PortForwardBean> getPortForwards() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
315 return null;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
316 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
317
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
318 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
319 * Whether or not this transport type can transfer files.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
320 * @return true on ability to transfer files
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
321 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
322 public boolean canTransferFiles() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
323 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
324 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
325
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
326 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
327 * Downloads the specified remote file to a local folder.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
328 * @param remoteFile The path to the remote file to be downloaded. Must be non-null.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
329 * @param localFolder The path to local folder. Null = default external storage folder.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
330 * @return true on success, false on failure
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
331 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
332 public boolean downloadFile(String remoteFile, String localFolder) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
333 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
334 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
335
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
336 /**
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
337 * Uploads the specified local file to the remote host.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
338 * @param localFile The path to the local file to be uploaded. Must be non-null.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
339 * @param remoteFolder The path to the remote directory. Null == default remote directory.
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
340 * @return true on success, false on failure
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
341 */
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
342 public boolean uploadFile(String localFile, String remoteFile,
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
343 String remoteFolder, String mode) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
344 return false;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
345 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
346
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
347 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
348 public int getDefaultPort() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
349 return DEFAULT_PORT;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
350 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
351
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
352 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
353 public boolean isConnected() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
354 return connected;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
355 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
356
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
357 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
358 public boolean isSessionOpen() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
359 return connected;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
360 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
361
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
362 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
363 public boolean isAuthenticated() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
364 return connected;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
365 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
366
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
367
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
368 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
369 public String getDefaultNickname(String username, String hostname, int port) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
370 if (port == DEFAULT_PORT) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
371 return String.format("%s", hostname);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
372 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
373 else {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
374 return String.format("%s:%d", hostname, port);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
375 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
376 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
377
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
378 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
379 public void getSelectionArgs(Uri uri, Map<String, String> selection) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
380 selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
381 selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
382 selection.put(HostDatabase.FIELD_HOST_HOSTNAME, uri.getHost());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
383 int port = uri.getPort();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
384
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
385 if (port < 0)
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
386 port = DEFAULT_PORT;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
387
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
388 selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port));
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
389 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
390
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
391
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
392 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
393 public HostBean createHost(Uri uri) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
394 HostBean host = new HostBean();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
395 host.setProtocol(PROTOCOL);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
396 host.setHostname(uri.getHost());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
397 int port = uri.getPort();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
398
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
399 if (port < 0)
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
400 port = DEFAULT_PORT;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
401
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
402 host.setPort(port);
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
403 String nickname = uri.getFragment();
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
404
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
405 if (nickname == null || nickname.length() == 0) {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
406 host.setNickname(getDefaultNickname(host.getUsername(),
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
407 host.getHostname(), host.getPort()));
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
408 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
409 else {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
410 host.setNickname(uri.getFragment());
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
411 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
412
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
413 return host;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
414 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
415
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
416
12
6aaefb22d876 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents: 11
diff changeset
417 public String getFormatHint(Context context) {
11
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
418 return String.format("%s:%s",
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
419 context.getString(R.string.format_hostname),
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
420 context.getString(R.string.format_port));
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
421 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
422
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
423
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
424 @Override
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
425 public boolean usesNetwork() {
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
426 return true;
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
427 }
f3b3bbd227b8 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
428 }