comparison app/src/main/java/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 470:2cc170e3fc9b stable-1.9.3-8

audible bell checkbox enables/disables bell volume setting; monitor init string is now a url socket://target/initstring
author Carl Byington <carl@five-ten-sg.com>
date Fri, 04 Oct 2019 16:44:44 -0700
parents 4776062555f3
children d7461da8145b
comparison
equal deleted inserted replaced
469:fbb1a98998fb 470:2cc170e3fc9b
62 public static final char CURSOR_REQUESTED = 0; 62 public static final char CURSOR_REQUESTED = 0;
63 public static final char CURSOR_SCREEN_CHANGE = 1; 63 public static final char CURSOR_SCREEN_CHANGE = 1;
64 public static final char CURSOR_USER_KEY = 2; 64 public static final char CURSOR_USER_KEY = 2;
65 65
66 private static final int MONITORPORT = 6000; 66 private static final int MONITORPORT = 6000;
67 private static final String LOCALHOST = "127.0.0.1";
68 67
69 private Context parent = null; 68 private Context parent = null;
70 private vt320 buffer = null; 69 private vt320 buffer = null;
71 private View view = null; 70 private View view = null;
72 private HostBean host = null; 71 private HostBean host = null;
72 private Uri uri = null;
73 private String target = null;
73 private String init = null; 74 private String init = null;
74 private int start_line = 0; // monitor part of the screen for changes 75 private int start_line = 0; // monitor part of the screen for changes
75 private int end_line = 500; // "" 76 private int end_line = 500; // ""
76 private int start_column = 0; // "" 77 private int start_column = 0; // ""
77 private int end_column = 500; // "" 78 private int end_column = 500; // ""
188 public void onServiceConnected(ComponentName className, IBinder service) { 189 public void onServiceConnected(ComponentName className, IBinder service) {
189 bound = service; 190 bound = service;
190 Log.i(TAG, "bound to service"); 191 Log.i(TAG, "bound to service");
191 192
192 try { 193 try {
193 InetAddress serverAddr = InetAddress.getByName(LOCALHOST); 194 InetAddress serverAddr = InetAddress.getByName(target);
194 int tries = 0; 195 int tries = 0;
195 while (tries < 10) { 196 while (tries < 10) {
196 try { 197 try {
197 Thread.sleep(100); 198 Thread.sleep(100);
198 monitor_socket = new Socket(serverAddr, MONITORPORT); 199 monitor_socket = new Socket(serverAddr, MONITORPORT);
232 Log.i(TAG, "unbound from service"); 233 Log.i(TAG, "unbound from service");
233 } 234 }
234 }; 235 };
235 236
236 237
237 public TerminalMonitor(Context parent, vt320 buffer, View view, HostBean host, String init) { 238 public TerminalMonitor(Context parent, vt320 buffer, View view, HostBean host, String url) {
238 this.parent = parent; 239 this.parent = parent;
239 this.buffer = buffer; 240 this.buffer = buffer;
240 this.view = view; 241 this.view = view;
241 this.host = host; 242 this.host = host;
242 this.init = init; 243 this.uri = Uri.parse(url);
244 this.target = uri.getHost();
245 this.init = uri.getPath();
243 // setup the windows->android keymapping 246 // setup the windows->android keymapping
244 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 247 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731
245 keymap = new HashMap<Integer, Integer>(); 248 keymap = new HashMap<Integer, Integer>();
246 keymap.put(0x08, vt320.KEY_BACK_SPACE); // vk_back 249 keymap.put(0x08, vt320.KEY_BACK_SPACE); // vk_back
247 keymap.put(0x09, vt320.KEY_TAB); // vk_tab 250 keymap.put(0x09, vt320.KEY_TAB); // vk_tab