Mercurial > 510Connectbot
changeset 91:33eb63352be5
remove 5250 configuration
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 16 Jun 2014 16:17:48 -0700 |
parents | 3f587bd647a5 |
children | e5259eab903e |
files | src/com/five_ten_sg/connectbot/TerminalView.java src/com/five_ten_sg/connectbot/service/TerminalBridge.java src/com/five_ten_sg/connectbot/transport/AbsTransport.java src/com/five_ten_sg/connectbot/transport/TN5250.java src/org/tn5250j/GlobalConfigure.java src/org/tn5250j/framework/tn5250/tnvt.java src/org/tn5250j/framework/transport/SSL/SSLImplementation.java src/org/tn5250j/framework/transport/SocketConnector.java src/org/tn5250j/interfaces/ConfigureFactory.java |
diffstat | 9 files changed, 22 insertions(+), 646 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/TerminalView.java Mon Jun 16 12:34:05 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/TerminalView.java Mon Jun 16 16:17:48 2014 -0700 @@ -61,7 +61,8 @@ public class TerminalView extends View implements FontSizeChangedListener { private final Context context; - public final TerminalBridge bridge; + public final TerminalBridge bridge; + public final String homeDirectory = ""; private final Paint paint; private final Paint cursorPaint; private final Paint cursorStrokePaint; @@ -85,7 +86,6 @@ private Matcher mCodeMatcher = null; private AccessibilityEventSender mEventSender = null; - public static String android_home_directory = ""; private static final String BACKSPACE_CODE = "\\x08\\x1b\\[K"; private static final String CONTROL_CODE_PATTERN = "\\x1b\\[K[^m]+[m|:]"; @@ -98,9 +98,9 @@ public TerminalView(Context context, TerminalBridge bridge) { super(context); - android_home_directory = context.getApplicationInfo().dataDir; - this.context = context; - this.bridge = bridge; + this.context = context; + this.bridge = bridge; + this.homeDirectory = context.getApplicationInfo().dataDir; paint = new Paint(); setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); setFocusable(true);
--- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Mon Jun 16 12:34:05 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Mon Jun 16 16:17:48 2014 -0700 @@ -211,7 +211,7 @@ */ protected void startConnection() { transport = TransportFactory.getTransport(host.getProtocol()); - transport.setLinks(manager, this, host, emulation); + transport.setLinks(manager, this, parent.homeDirectory, host, emulation); buffer = transport.getTransportBuffer(); keyListener = transport.getTerminalKeyListener();
--- a/src/com/five_ten_sg/connectbot/transport/AbsTransport.java Mon Jun 16 12:34:05 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/transport/AbsTransport.java Mon Jun 16 16:17:48 2014 -0700 @@ -39,6 +39,7 @@ protected String TAG; protected TerminalManager manager; protected TerminalBridge bridge; + protected String homeDirectory; protected HostBean host; protected vt320 buffer = null; protected String emulation; @@ -257,11 +258,12 @@ return setupTransportBuffer(); } - public void setLinks(TerminalManager manager, TerminalBridge bridge, HostBean host, String emulation) { - this.manager = manager; - this.bridge = bridge; - this.host = host; - this.emulation = emulation; + public void setLinks(TerminalManager manager, TerminalBridge bridge, String homeDirectory, HostBean host, String emulation) { + this.manager = manager; + this.bridge = bridge; + this.homeDirectory = homeDirectory; + this.host = host; + this.emulation = emulation; } /**
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java Mon Jun 16 12:34:05 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java Mon Jun 16 16:17:48 2014 -0700 @@ -255,10 +255,9 @@ handler = new tnvt(screen52, true, false, bridge, manager); String encryption = host.getEncryption5250(); if ((encryption == null) || (encryption.length() == 0)) encryption = "NONE"; - handler.setSSLType(encryption); screen52.setVT(handler); screen52.setBuffer(buffer); - connected = handler.connect(host.getHostname(), host.getPort(), buffer); + connected = handler.connect(host.getHostname(), host.getPort(), encryption, homeDirectory, buffer); if (connected) bridge.onConnected(); }
--- a/src/org/tn5250j/GlobalConfigure.java Mon Jun 16 12:34:05 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,508 +0,0 @@ -/** - * Title: GlobalConfigure.java - * Copyright: Copyright (c) 2001, 2002, 2003 - * Company: - * @author Kenneth J. Pouncey - * @version 0.1 - * - * Description: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - * - */ -package org.tn5250j; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Hashtable; -import java.util.Properties; - -import com.five_ten_sg.connectbot.TerminalView; -import org.tn5250j.interfaces.ConfigureFactory; -import android.util.Log; - - -/** - * Utility class for referencing global settings and functions of which at most - * one instance can exist per VM. - * - * Use GlobalConfigure.instance() to access this instance. - */ -public class GlobalConfigure extends ConfigureFactory { - private static final String TAG = "GlobalConfigure"; - public static final String TN5250J_FOLDER = ".tn5250j"; - - /** - * A handle to the unique GlobalConfigure class - */ - static private GlobalConfigure _instance; - - /** - * A handle to the the Global Properties - */ - static private Properties settings; - - static private Hashtable registry = new Hashtable(); - static private Hashtable headers = new Hashtable(); //LUC GORRENS - - - /** - * The constructor is made protected to allow overriding. - */ - public GlobalConfigure() { - if (_instance == null) { - // initialize the settings information - initialize(); - // set our instance to this one. - _instance = this; - } - } - - /** - * - * @return The unique instance of this class. - */ - static public GlobalConfigure instance() { - - if (_instance == null) { - _instance = new GlobalConfigure(); - } - return _instance; - - } - - /** - * Initialize the properties registry for use later. - * - */ - private void initialize() { - verifySettingsFolder(); - loadSettings(); - loadSessions(); - loadMacros(); - loadKeyStrokes(); - } - - /** - * check if folder %USERPROFILE%/.tn5250j exists - * and create if necessary - */ - private void verifySettingsFolder() { - final String settingsfolder = settingsFolder(); - final File f = new File (settingsfolder); - if (!f.exists()) { - try { - Log.i(TAG,"Settings folder '"+settingsfolder+"' doesn't exist. Will created now."); - f.mkdir(); - } catch (Exception e) { - Log.w(TAG,"Couldn't create settings folder '"+settingsfolder+"'", e); - } - } - } - - /** - * Load the sessions properties - */ - private void loadSessions() { - - setProperties(SESSIONS,SESSIONS,"------ Sessions --------",true); - } - - /** - * Load the macros - */ - private void loadMacros() { - - setProperties(MACROS,MACROS,"------ Macros --------",true); - - } - - private void loadKeyStrokes() { - - setProperties(KEYMAP,KEYMAP, - "------ Key Map key=keycode,isShiftDown,isControlDown,isAltDown,isAltGrDown --------", - true); - - } - - /** - * Reload the environment settings. - */ - @Override - public void reloadSettings() { - Log.i(TAG,"reloading settings"); - loadSettings(); - loadSessions(); - loadMacros(); - loadKeyStrokes(); - Log.i(TAG,"Done (reloading settings)."); - } - - /** - * Loads the emulator setting from the setting(s) file - */ - private void loadSettings() { - - FileInputStream in = null; - settings = new Properties(); - - try { - in = new FileInputStream(settingsFile()); - settings.load(in); - } - catch (FileNotFoundException fnfea) { - Log.i(TAG," Information Message: " - + fnfea.getMessage() + ". The file " + settingsFile() - + " will be created for first time use."); - saveSettings(); - } - catch (IOException ioea) { - Log.w(TAG,"IO Exception accessing File " - + settingsFile() + " for the following reason : " - + ioea.getMessage()); - } - catch (SecurityException sea) { - Log.w(TAG,"Security Exception for file " - + settingsFile() + " This file can not be " - + "accessed because : " + sea.getMessage()); - } - } - - /** - * Save the settings for the global configuration - */ - @Override - public void saveSettings() { - - try { - FileOutputStream out = new FileOutputStream(settingsFile()); - settings.store(out,"----------------- tn5250j Global Settings --------------"); - } - catch (FileNotFoundException fnfe) {} - catch (IOException ioe) {} - } - - /** - * Save the setting in the registry using the key passed in with no header - * output. - * - * @param regKey - */ - @Override - public void saveSettings(String regKey) { - - saveSettings(regKey,""); - } - - /** - * Save the settings in the registry using the key passed with a header - * in the output. - * - * @param regKey - * @param Header - */ - @Override - public void saveSettings(String regKey, String header) { - - saveSettings(regKey,regKey,header); - } - - /** - * Save the settings in the registry using the key passed with a header - * in the output. - * - * @param regKey - * @param Header - */ - @Override - public void saveSettings(String regKey, String fileName, String header) { - - if (registry.containsKey(regKey)) { - try { - FileOutputStream out = new FileOutputStream( - settingsDirectory() + fileName); - Properties props = (Properties)registry.get(regKey); - props.store(out,header); - out.flush(); - out.close(); - } - catch (FileNotFoundException fnfe) { - Log.w(TAG,"File not found : writing file " - + fileName + ". Description of error is " - + fnfe.getMessage()); - } - catch (IOException ioe) { - Log.w(TAG,"IO Exception : writing file " - + fileName + ". Description of error is " - + ioe.getMessage()); - } - catch (SecurityException se) { - Log.w(TAG,"Security Exception : writing file " - + fileName + ". Description of error is " - + se.getMessage()); - } - - } - - } - - /** - * Place the Properties in the registry under a given registry name - * - * @param regKey - * @param regProps - */ - @Override - public void setProperties(String regKey, Properties regProps) { - - registry.put(regKey, regProps); - - } - - /** - * Set the properties for the given registry key. - * - * @param regKey - * @param fileName - * @param header - */ - @Override - public void setProperties(String regKey, String fileName, String header) { //LG NEW - setProperties(regKey, fileName, header, false); - } - - /** - * Set the properties for the given registry key. - * - * @param regKey - * @param fileName - * @param header - * @param createFile - */ - @Override - public void setProperties(String regKey, String fileName, String header, - boolean createFile) { - - FileInputStream in = null; - Properties props = new Properties(); - headers.put(regKey, header); - - try { - in = new FileInputStream(settingsDirectory() + fileName); - props.load(in); - - } - catch (FileNotFoundException fnfe) { - - if (createFile) { - Log.i(TAG," Information Message: " + fnfe.getMessage() - + ". The file " + fileName + " will" - + " be created for first time use."); - - saveSettings(regKey,header); - - } - else { - - Log.i(TAG," Information Message: " + fnfe.getMessage() - + "."); - - } - } - catch (IOException ioe) { - Log.w(TAG,"IO Exception accessing File "+ fileName + - " for the following reason : " - + ioe.getMessage()); - } - catch (SecurityException se) { - Log.w(TAG,"Security Exception for file "+ fileName - + ". This file can not be accessed because : " - + se.getMessage()); - } - - registry.put(regKey,props); - - } - - /** - * Returns the properties associated with a given registry key. - * - * @param regKey - * @return - */ - @Override - public Properties getProperties(String regKey) { - - if (registry.containsKey(regKey)) { - return (Properties)registry.get(regKey); - } - return null; - } - - public Properties getProperties() { - return settings; - } - - @Override - public Properties getProperties(String regKey,String fileName) { - return getProperties(regKey,fileName,false,"",false); - } - - @Override - public Properties getProperties(String regKey,String fileName, - boolean createFile, String header) { - return getProperties(regKey,fileName,false,"",false); - } - - @Override - public Properties getProperties(String regKey, - String fileName, - boolean createFile, - String header, - boolean reloadIfLoaded) { - - if (!registry.containsKey(regKey) || reloadIfLoaded) { - - FileInputStream in = null; - Properties props = new Properties(); - headers.put(regKey, header); - - try { - in = new FileInputStream(settingsDirectory() - + fileName); - props.load(in); - - } - catch (FileNotFoundException fnfe) { - - if (createFile) { - Log.i(TAG," Information Message: " + fnfe.getMessage() - + ". The file " + fileName + " will" - + " be created for first time use."); - - registry.put(regKey,props); - - saveSettings(regKey,header); - - return props; - - } - else { - - Log.i(TAG," Information Message: " + fnfe.getMessage() - + "."); - - } - } - catch (IOException ioe) { - Log.w(TAG,"IO Exception accessing File "+ fileName + - " for the following reason : " - + ioe.getMessage()); - } - catch (SecurityException se) { - Log.w(TAG,"Security Exception for file "+ fileName - + ". This file can not be accessed because : " - + se.getMessage()); - } - - registry.put(regKey,props); - - return props; - } - else { - return (Properties)registry.get(regKey); - } - } - - /** - * Returns the setting from the given key of the global properties or the - * default passed if the property does not exist. - * - * @param key - * @param def - * @return - */ - @Override - public String getProperty(String key, String def) { - if (settings.containsKey(key)) - return settings.getProperty(key); - else - return def; - } - - /** - * Returns the setting from the given key of the global properties. - * - * @param key - * @return - */ - @Override - public String getProperty(String key) { - return settings.getProperty(key); - } - - /** - * Private helper to return the full path to the settings file - * - * @return - */ - private String settingsFile() { - return settingsDirectory() + "tn5250jstartup.cfg"; - - } - - /** - * helper to return the settings directory - * - * @return - */ - public String settingsDirectory() { - return settingsFolder() + File.separator; - - } - - /** - * Private helper to return the settings folder path - * - * @return - */ - private String settingsFolder() { - return TerminalView.android_home_directory + File.separator + TN5250J_FOLDER; - - } - - /** - * Not sure yet so be careful using this. - * - * @return - */ - public ClassLoader getClassLoader() { - - ClassLoader loader = GlobalConfigure.class.getClassLoader(); - if (loader == null) - loader = ClassLoader.getSystemClassLoader(); - - return loader; - } - -}
--- a/src/org/tn5250j/framework/tn5250/tnvt.java Mon Jun 16 12:34:05 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/tnvt.java Mon Jun 16 16:17:48 2014 -0700 @@ -217,10 +217,6 @@ return hostname; } - public void setSSLType(String type) { - sslType = type; - } - public void setDeviceName(String name) { devName = name; } @@ -260,7 +256,7 @@ Log.i(TAG," socks set "); } - public final boolean connect(String hostname, int port, vt320 buffer) { + public final boolean connect(String hostname, int port, String encryption, String homeDirectory, vt320 buffer) { try { this.hostname = hostname; this.port = port; @@ -273,8 +269,7 @@ } SocketConnector sc = new SocketConnector(); - if (sslType != null) sc.setSSLType(sslType); - sock = sc.createSocket(hostname, port, bridge, manager); + sock = sc.createSocket(hostname, port, encryption, homeDirectory, bridge, manager); if (sock == null) { Log.w(TAG,"I did not get a socket");
--- a/src/org/tn5250j/framework/transport/SSL/SSLImplementation.java Mon Jun 16 12:34:05 2014 -0700 +++ b/src/org/tn5250j/framework/transport/SSL/SSLImplementation.java Mon Jun 16 16:17:48 2014 -0700 @@ -42,7 +42,6 @@ import com.five_ten_sg.connectbot.service.TerminalBridge; import com.five_ten_sg.connectbot.service.TerminalManager; -import org.tn5250j.GlobalConfigure; import org.tn5250j.framework.transport.SSLInterface; import android.util.Log; @@ -81,10 +80,10 @@ } - public void init(String sslType) { + public void init(String sslType, String homeDirectory) { try { Log.d(TAG,"Initializing User KeyStore"); - userKsPath = GlobalConfigure.instance().settingsDirectory() + "keystore"; + userKsPath = homeDirectory + File.separator + "keystore"; File userKsFile = new File(userKsPath); userks = KeyStore.getInstance(KeyStore.getDefaultType()); userks.load(userKsFile.exists() ? new FileInputStream(userKsFile)
--- a/src/org/tn5250j/framework/transport/SocketConnector.java Mon Jun 16 12:34:05 2014 -0700 +++ b/src/org/tn5250j/framework/transport/SocketConnector.java Mon Jun 16 16:17:48 2014 -0700 @@ -35,7 +35,6 @@ public class SocketConnector { private static final String TAG = "SocketConnector"; - String sslType = null; /** * Creates a new instance that creates a plain socket by default. @@ -45,25 +44,13 @@ } /** - * Set the type of SSL connection to use. Specify null or an empty string - * to use a plain socket. - * @param type The SSL connection type - * @see org.tn5250j.framework.transport.SSLConstants - */ - public void setSSLType(String type) { - sslType = type; - } - - /** - * Create a new client Socket to the given destination and port. If an SSL - * socket type has not been specified <i>(by setSSLType(String))</i>, then - * a plain socket will be created. Otherwise, a new SSL socket of the - * specified type will be created. + * Create a new client Socket to the given destination, port and sslType of + * encryption. * @param destination * @param port * @return a new client socket, or null if */ - public Socket createSocket(String destination, int port, TerminalBridge bridge, TerminalManager manager) { + public Socket createSocket(String destination, int port, String sslType, String homeDirectory, TerminalBridge bridge, TerminalManager manager) { Socket socket = null; Exception ex = null; @@ -91,7 +78,7 @@ } if (sslIf != null) { - sslIf.init(sslType); + sslIf.init(sslType, homeDirectory); socket = sslIf.createSSLSocket(destination, port); } }
--- a/src/org/tn5250j/interfaces/ConfigureFactory.java Mon Jun 16 12:34:05 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * @(#)ConfigureFactory.java - * @author Kenneth J. Pouncey - * Modified by LDC Luc - * - * Copyright: Copyright (c) 2001, 2002, 2003 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - * - */ -package org.tn5250j.interfaces; - -import org.tn5250j.GlobalConfigure; -import java.util.Properties; - -/** - * An interface defining objects that can create Configure - * instances. - */ -public abstract class ConfigureFactory { - - static final public String SESSIONS = "sessions"; - static final public String MACROS = "macros"; - static final public String KEYMAP = "keymap"; - private static ConfigureFactory factory; - - /** - * @return An instance of the Configure. - */ - public static ConfigureFactory getInstance() - { - ConfigureFactory.setFactory(); - return factory; - } - - private static final void setFactory() - { - if (factory == null) - { - try - { - String className = System.getProperty(ConfigureFactory.class.getName()); - if (className != null) - { - Class<?> classObject = Class.forName(className); - Object object = classObject.newInstance(); - if (object instanceof ConfigureFactory) - { - ConfigureFactory.factory = (ConfigureFactory) object; - } - } - } - catch (Exception ex) - { - ; - } - if (ConfigureFactory.factory == null) - { //take the default -// ConfigureFactory.factory = new GlobalConfigureFactory(); - ConfigureFactory.factory = new GlobalConfigure(); - } - } - } - - abstract public void reloadSettings(); - abstract public void saveSettings(); - abstract public String getProperty(String regKey); - abstract public String getProperty(String regKey, String defaultValue); - abstract public void setProperties(String regKey, Properties regProps); - - abstract public void setProperties(String regKey, String fileName, String header); - abstract public void setProperties(String regKey, String fileName, String header, - boolean createFile); - abstract public Properties getProperties(String regKey); - abstract public Properties getProperties(String regKey,String fileName); - abstract public Properties getProperties(String regKey,String fileName, - boolean createFile, String header); - abstract public Properties getProperties(String regKey,String fileName, - boolean createFile, String header, - boolean reloadIfLoaded); - abstract public void saveSettings(String regKey); - abstract public void saveSettings(String regKey, String header); - abstract public void saveSettings(String regKey, String fileName, String header); - -} \ No newline at end of file