changeset 26:9ae1c889a64c tn5250

adding tn5250 files, native android logging
author Carl Byington <carl@five-ten-sg.com>
date Tue, 03 Jun 2014 12:16:46 -0700
parents 5949eb469a79
children b29b39f386a4
files src/org/tn5250j/framework/tn5250/Screen5250.java src/org/tn5250j/framework/tn5250/tnvt.java src/org/tn5250j/framework/transport/SSL/SSLImplementation.java src/org/tn5250j/framework/transport/SocketConnector.java
diffstat 4 files changed, 15 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tn5250j/framework/tn5250/Screen5250.java	Tue Jun 03 12:10:21 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/Screen5250.java	Tue Jun 03 12:16:46 2014 -0700
@@ -39,7 +39,7 @@
 
 
 public class Screen5250 {
-
+    private static final String TAG = "Screen5250";
 	private ScreenFields screenFields;
 	private int lastAttr;
 	private int lastPos;
--- a/src/org/tn5250j/framework/tn5250/tnvt.java	Tue Jun 03 12:10:21 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/tnvt.java	Tue Jun 03 12:16:46 2014 -0700
@@ -94,6 +94,7 @@
 
 
 public final class tnvt implements Runnable {
+    private static final String TAG = "tnvt";
     // negotiating commands
     private static final byte IAC = (byte) -1; // 255 FF
     private static final byte DONT = (byte) -2; //254 FE
--- a/src/org/tn5250j/framework/transport/SSL/SSLImplementation.java	Tue Jun 03 12:10:21 2014 -0700
+++ b/src/org/tn5250j/framework/transport/SSL/SSLImplementation.java	Tue Jun 03 12:16:46 2014 -0700
@@ -57,9 +57,8 @@
  *
  */
 public class SSLImplementation implements SSLInterface, X509TrustManager {
-
+    private static final String TAG = "SSLImplementation";
 	SSLContext sslContext = null;
-
 	KeyStore userks = null;
 	private String userKsPath;
 	private char[] userksPassword = "changeit".toCharArray();
@@ -76,8 +75,6 @@
 
 	X509Certificate[] acceptedIssuers;
 
-	TN5250jLogger logger;
-
 	public SSLImplementation(TerminalBridge bridge, TerminalManager manager) {
         this.bridge  = bridge;
         this.manager = manager;
@@ -86,27 +83,27 @@
 
 	public void init(String sslType) {
 		try {
-			logger.debug("Initializing User KeyStore");
+			Log.d(TAG,"Initializing User KeyStore");
 			userKsPath = System.getProperty("user.home") + File.separator
 					+ GlobalConfigure.TN5250J_FOLDER + File.separator + "keystore";
 			File userKsFile = new File(userKsPath);
 			userks = KeyStore.getInstance(KeyStore.getDefaultType());
 			userks.load(userKsFile.exists() ? new FileInputStream(userKsFile)
 					: null, userksPassword);
-			logger.debug("Initializing User Key Manager Factory");
+			Log.d(TAG,"Initializing User Key Manager Factory");
 			userkmf = KeyManagerFactory.getInstance(KeyManagerFactory
 					.getDefaultAlgorithm());
 			userkmf.init(userks, userksPassword);
-			logger.debug("Initializing User Trust Manager Factory");
+			Log.d(TAG,"Initializing User Trust Manager Factory");
 			usertmf = TrustManagerFactory.getInstance(TrustManagerFactory
 					.getDefaultAlgorithm());
 			usertmf.init(userks);
 			userTrustManagers = usertmf.getTrustManagers();
-			logger.debug("Initializing SSL Context");
+			Log.d(TAG,"Initializing SSL Context");
 			sslContext = SSLContext.getInstance(sslType);
 			sslContext.init(userkmf.getKeyManagers(), new TrustManager[] {this}, null);
 		} catch (Exception ex) {
-			logger.error("Error initializing SSL [" + ex.getMessage() + "]");
+			Log.e(TAG,"Error initializing SSL [" + ex.getMessage() + "]");
 		}
 
 	}
@@ -120,7 +117,7 @@
 			socket = (SSLSocket) sslContext.getSocketFactory().createSocket(
 					destination, port);
 		} catch (Exception e) {
-			logger.error("Error creating ssl socket [" + e.getMessage() + "]");
+			Log.e(TAG,"Error creating ssl socket [" + e.getMessage() + "]");
 		}
 		return socket;
 	}
@@ -207,7 +204,7 @@
 					userks.store(new FileOutputStream(userKsPath),
 							userksPassword);
 				} catch (Exception e) {
-					logger.error("Error saving certificate [" + e.getMessage()
+					Log.e(TAG,"Error saving certificate [" + e.getMessage()
 							+ "]");
 					e.printStackTrace();
 				}
--- a/src/org/tn5250j/framework/transport/SocketConnector.java	Tue Jun 03 12:10:21 2014 -0700
+++ b/src/org/tn5250j/framework/transport/SocketConnector.java	Tue Jun 03 12:16:46 2014 -0700
@@ -34,11 +34,9 @@
 
 
 public class SocketConnector {
-
+    private static final String TAG = "SocketConnector";
   String sslType = null;
 
-  TN5250jLogger logger;
-
   /**
    * Creates a new instance that creates a plain socket by default.
    */
@@ -72,7 +70,7 @@
 
       if (sslType == null || sslType.trim().length() == 0 ||
       		sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) {
-        	logger.info("Creating Plain Socket");
+        	Log.i(TAG,"Creating Plain Socket");
         try {
 			// Use Socket Constructor!!! SocketFactory for jdk 1.4
 			socket = new Socket(destination,port);
@@ -81,7 +79,7 @@
 		}
       } else {  //SSL SOCKET
 
-   		logger.info("Creating SSL ["+sslType+"] Socket");
+   		Log.i(TAG,"Creating SSL ["+sslType+"] Socket");
 
       	SSLInterface sslIf = null;
 
@@ -99,10 +97,10 @@
       }
 
       if (ex != null) {
-      	logger.error(ex);
+      	Log.e(TAG,ex);
       }
       if (socket == null) {
-      	logger.warn("No socket was created");
+      	Log.w(TAG,"No socket was created");
       }
       return socket;
   }