tn5250j/src/org/tn5250j Session5250.java,NONE,1.1 SessionBean.java,1.1,1.2 ScreenPlanes.java,1.5,1.6
"Kenneth J. Pouncey" <[email protected]> Thu, 22 Jul 2004 04:55:32 +0000
| Newsgroups | gmane.comp.java.tn5250j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4493/src/org/tn5250j
Modified Files:
SessionBean.java ScreenPlanes.java
Added Files:
Session5250.java
Log Message:
Updates for headless
Index: SessionBean.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/SessionBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SessionBean.java 18 Jul 2004 13:43:58 -0000 1.1
--- SessionBean.java 22 Jul 2004 04:55:29 -0000 1.2
***************
*** 5,12 ****
* <p>Copyright: Copyright (c) 2000 - 2004</p>
* <p>
! *
* @author Luc Gorrens
* @version 1.0
! *
* 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
--- 5,12 ----
* <p>Copyright: Copyright (c) 2000 - 2004</p>
* <p>
! *
* @author Luc Gorrens
* @version 1.0
! *
* 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
***************
*** 47,55 ****
import org.tn5250j.interfaces.ConfigureFactory;
!
public class SessionBean
! extends Session
{
// // ===========================================================================
--- 47,55 ----
import org.tn5250j.interfaces.ConfigureFactory;
! import org.tn5250j.Session5250;
public class SessionBean
! extends SessionGUI
{
// // ===========================================================================
***************
*** 69,76 ****
String sessionName)
{
! super(sessionProperties, null, sessionName, new SessionConfig(configurationResource, sessionName));
! this.sessionProperties = sessionProperties;
this.sessionProperties.put(SESSION_LOCALE, Locale.getDefault());
! this.getConfiguration().addSessionConfigListener(this);
}
--- 69,88 ----
String sessionName)
{
!
! // Session52520 session = new Session5250(sessionProperties, null, sessionName, new SessionConfig(configurationResource, sessionName));
! this(new Session5250(sessionProperties, null, sessionName,
! new SessionConfig(configurationResource, sessionName)));
! // super(sessionProperties, null, sessionName, new SessionConfig(configurationResource, sessionName));
! // this.sessionProperties = sessionProperties;
! // this.sessionProperties.put(SESSION_LOCALE, Locale.getDefault());
! // this.getConfiguration().addSessionConfigListener(this);
! }
!
! public SessionBean(Session5250 session) {
!
! super(session);
! this.sessionProperties = session.sesProps;
this.sessionProperties.put(SESSION_LOCALE, Locale.getDefault());
! this.getSession().getConfiguration().addSessionConfigListener(this);
}
***************
*** 271,278 ****
public void signoff()
{
! if (vt != null)
{
if (this.isConnected())
! this.vt.systemRequest("90");
}
}
--- 283,290 ----
public void signoff()
{
! if (session.getVT() != null)
{
if (this.isConnected())
! this.session.getVT().systemRequest("90");
}
}
***************
*** 280,284 ****
public void systemRequest(String srCode)
{
! this.vt.systemRequest(srCode);
}
--- 292,296 ----
public void systemRequest(String srCode)
{
! this.session.getVT().systemRequest(srCode);
}
***************
*** 465,469 ****
private void failIfConnected()
{
! if ((vt != null) && (isConnected()))
throw new IllegalStateException("Cannot change property after being connected!");
}
--- 477,481 ----
private void failIfConnected()
{
! if ((session.getVT() != null) && (isConnected()))
throw new IllegalStateException("Cannot change property after being connected!");
}
--- NEW FILE: Session5250.java ---
/*
* @(#)Session5250.java
* Copyright: Copyright (c) 2001
*
* 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.util.*;
import java.awt.Rectangle;
import org.tn5250j.interfaces.SessionInterface;
import org.tn5250j.event.SessionListener;
import org.tn5250j.event.SessionChangeEvent;
import org.tn5250j.interfaces.ScanListener;
/**
* A host session
*/
public class Session5250 implements SessionInterface,TN5250jConstants {
private String configurationResource;
private String sessionName;
private boolean connected;
private int sessionType;
protected Properties sesProps;
private Vector listeners;
private SessionChangeEvent sce;
private String sslType;
private boolean firstScreen;
private char[] signonSave;
private boolean heartBeat;
String propFileName;
protected SessionConfig sesConfig;
tnvt vt;
Screen5250 screen;
SessionGUI guiComponent;
// WVL - LDC : TR.000300 : Callback scenario from 5250
private boolean scan; // = false;
private ScanListener scanListener; // = null;
public Session5250 (Properties props, String configurationResource,
String sessionName,
SessionConfig config) {
// super(config);
propFileName = config.getConfigurationResource();
sesConfig = config;
this.configurationResource = configurationResource;
this.sessionName = sessionName;
sesProps = props;
sce = new SessionChangeEvent(this);
if (sesProps.containsKey(SESSION_HEART_BEAT))
heartBeat = true;
screen = new Screen5250(sesConfig);
screen.setVT(vt);
}
public String getConfigurationResource() {
return configurationResource;
}
public SessionConfig getConfiguration() {
return sesConfig;
}
public SessionManager getSessionManager() {
return SessionManager.instance();
}
public boolean isConnected() {
return vt.isConnected();
}
protected boolean isSendKeepAlive() {
return heartBeat;
}
public void setGUI (SessionGUI gui) {
guiComponent = gui;
}
public SessionGUI getGUI() {
return guiComponent;
}
// public boolean isOnSignOnScreen() {
//
// // check to see if we should check.
// if (firstScreen) {
//
// char[] so = screen.getScreenAsChars();
// int size = signonSave.length;
//
// Rectangle region = super.sesConfig.getRectangleProperty("signOnRegion");
//
// int fromRow = region.x;
// int fromCol = region.y;
// int toRow = region.width;
// int toCol = region.height;
//
// // make sure we are within range.
// if (fromRow == 0)
// fromRow = 1;
// if (fromCol == 0)
// fromCol = 1;
// if (toRow == 0)
// toRow = 24;
// if (toCol == 0)
// toCol = 80;
//
// int pos = 0;
//
// for (int r = fromRow; r <= toRow; r++)
// for (int c =fromCol;c <= toCol; c++) {
// pos = screen.getPos(r - 1, c - 1);
// // System.out.println(signonSave[pos]);
// if (signonSave[pos] != so[pos])
// return false;
// }
// }
//
// return true;
// }
public String getSessionName() {
return sessionName;
}
public String getAllocDeviceName() {
if (vt != null)
return vt.getAllocatedDeviceName();
else
return null;
}
public int getSessionType() {
return sessionType;
}
public String getHostName() {
return vt.getHostName();
}
public Screen5250 getScreen() {
return screen;
}
public void connect() {
String proxyPort = "1080"; // default socks proxy port
boolean enhanced = false;
boolean support132 = false;
int port = 23; // default telnet port
enhanced = sesProps.containsKey(SESSION_TN_ENHANCED);
if (sesProps.containsKey(SESSION_SCREEN_SIZE))
if (((String)sesProps.getProperty(SESSION_SCREEN_SIZE)).equals(SCREEN_SIZE_27X132_STR))
support132 = true;
final tnvt vt = new tnvt(screen,enhanced,support132);
setVT(vt);
vt.setController(this);
if (sesProps.containsKey(SESSION_PROXY_PORT))
proxyPort = (String)sesProps.getProperty(SESSION_PROXY_PORT);
if (sesProps.containsKey(SESSION_PROXY_HOST))
vt.setProxy((String)sesProps.getProperty(SESSION_PROXY_HOST),
proxyPort);
if (sesProps.containsKey(org.tn5250j.transport.SSLConstants.SSL_TYPE)) {
sslType = (String)sesProps.getProperty(org.tn5250j.transport.SSLConstants.SSL_TYPE);
}
else {
// set default to none
sslType = org.tn5250j.transport.SSLConstants.SSL_TYPE_NONE;
}
vt.setSSLType(sslType);
if (sesProps.containsKey(SESSION_CODE_PAGE))
vt.setCodePage((String)sesProps.getProperty(SESSION_CODE_PAGE));
if (sesProps.containsKey(SESSION_DEVICE_NAME))
vt.setDeviceName((String)sesProps.getProperty(SESSION_DEVICE_NAME));
if (sesProps.containsKey(SESSION_HOST_PORT)) {
port = Integer.parseInt((String)sesProps.getProperty(SESSION_HOST_PORT));
}
else {
// set to default 23 of telnet
port = 23;
}
final String ses = (String)sesProps.getProperty(SESSION_HOST);
final int portp = port;
// lets set this puppy up to connect within its own thread
Runnable connectIt = new Runnable() {
public void run() {
vt.connect(ses,portp);
}
};
// now lets set it to connect within its own daemon thread
// this seems to work better and is more responsive than using
// swingutilities's invokelater
Thread ct = new Thread(connectIt);
ct.setDaemon(true);
ct.start();
// addSessionListener(this);
}
public void disconnect() {
connected = false;
vt.disconnect();
}
// WVL - LDC : TR.000300 : Callback scenario from 5250
protected void setVT(tnvt v)
{
vt = v;
screen.setVT(vt);
if (vt != null)
vt.setScanningEnabled(this.scan);
}
public tnvt getVT() {
return vt;
}
// WVL - LDC : TR.000300 : Callback scenario from 5250
/**
* Enables or disables scanning.
*
* @param scan enables scanning when true; disables otherwise.
*
* @see tnvt#setCommandScanning(boolean);
* @see tnvt#isCommandScanning();
* @see tnvt#scan();
* @see tnvt#parseCommand();
* @see scanned(String,String)
*/
public void setScanningEnabled(boolean scan)
{
this.scan = scan;
if (this.vt != null)
this.vt.setScanningEnabled(scan);
}
// WVL - LDC : TR.000300 : Callback scenario from 5250
/**
* Checks whether scanning is enabled.
*
* @return true if command scanning is enabled; false otherwise.
*
* @see tnvt#setCommandScanning(boolean);
* @see tnvt#isCommandScanning();
* @see tnvt#scan();
* @see tnvt#parseCommand();
* @see scanned(String,String)
*/
public boolean isScanningEnabled()
{
if (this.vt != null)
return this.vt.isScanningEnabled();
return this.scan;
}
// WVL - LDC : TR.000300 : Callback scenario from 5250
/**
* This is the callback method for the TNVT when sensing the action cmd
* screen pattern (!# at position 0,0).
*
* This is <strong>NOT a threadsafe method</strong> and will be called
* from the TNVT read thread!
*
* @param command discovered in the 5250 stream.
* @param remainder are all the other characters on the screen.
*
* @see tnvt#setCommandScanning(boolean);
* @see tnvt#isCommandScanning();
* @see tnvt#scan();
* @see tnvt#parseCommand();
* @see scanned(String,String)
*/
protected void scanned(String command, String remainder)
{
if (scanListener != null)
scanListener.scanned(command, remainder);
}
public void addScanListener(ScanListener listener)
{
scanListener = ScanMulticaster.add(scanListener, listener);
}
public void removeScanListener(ScanListener listener)
{
scanListener = ScanMulticaster.remove(scanListener, listener);
}
/**
* Notify all registered listeners of the onSessionChanged event.
*
* @param state The state change property object.
*/
protected void fireSessionChanged(int state) {
switch (state) {
case TN5250jConstants.STATE_CONNECTED:
if (!firstScreen) {
firstScreen = true;
signonSave = screen.getScreenAsChars();
// System.out.println("Signon saved");
}
break;
default:
firstScreen = false;
signonSave = null;
}
if (listeners != null) {
int size = listeners.size();
for (int i = 0; i < size; i++) {
SessionListener target =
(SessionListener)listeners.elementAt(i);
sce.setState(state);
target.onSessionChanged(sce);
}
}
}
/**
* Add a SessionListener to the listener list.
*
* @param listener The SessionListener to be added
*/
public synchronized void addSessionListener(SessionListener listener) {
if (listeners == null) {
listeners = new java.util.Vector(3);
}
listeners.addElement(listener);
}
/**
* Remove a SessionListener from the listener list.
*
* @param listener The SessionListener to be removed
*/
public synchronized void removeSessionListener(SessionListener listener) {
if (listeners == null) {
return;
}
listeners.removeElement(listener);
}
}
Index: ScreenPlanes.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/ScreenPlanes.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ScreenPlanes.java 18 Jul 2004 13:38:54 -0000 1.5
--- ScreenPlanes.java 22 Jul 2004 04:55:29 -0000 1.6
***************
*** 89,94 ****
initalizePlanes();
- // if (numRows != oldRows)
- // fireScreenSizeChanged();
}
--- 89,92 ----
***************
*** 144,149 ****
for (int x = 0; x < numCols - 1; x++) {
- // screen[r + x].setCharAndAttr(errorLine[x].getChar(),
- // errorLine[x].getCharAttr(), false);
setScreenCharAndAttr(r+x,errorLine[x],errorLineAttr[x],
(errorLineIsAttr[x] == '1' ? true : false));
--- 142,145 ----
***************
*** 213,222 ****
screenGUI[pos] = (char)which;
- // if (which == NO_GUI) {
- // screenGUI[pos] = ;
- // }
- // else {
- // screenGUI[pos] = true;
- // }
}
--- 209,212 ----
***************
*** 297,301 ****
* @throws OhioException
*/
- // public int convertPosToRow(int pos) throws OhioException {
public int convertPosToRow(int pos) {
--- 287,290 ----
***************
*** 311,315 ****
* @throws OhioException
*/
- // public int convertPosToColumn(int pos) throws OhioException {
public int convertPosToColumn(int pos) {
--- 300,303 ----
***************
*** 327,331 ****
* @throws OhioException
*/
- // public int convertRowColToPos(int row, int col) throws OhioException {
public int convertRowColToPos(int row, int col) {
--- 315,318 ----
***************
*** 367,373 ****
* @throws OhioException
*/
! public synchronized int GetScreen(char buffer[], int bufferLength, int plane)
! // throws OhioException {
! {
return GetScreen(buffer,bufferLength,0,screenSize,plane);
--- 354,359 ----
* @throws OhioException
*/
! public synchronized int GetScreen(char buffer[], int bufferLength, int plane) {
!
return GetScreen(buffer,bufferLength,0,screenSize,plane);
***************
*** 400,404 ****
public synchronized int GetScreen(char buffer[], int bufferLength, int from,
int length, int plane)
- // throws OhioException {
{
// if(buffer == null)
--- 386,389 ----
***************
*** 590,676 ****
}
- // public final char getChar() {
- // return sChar[0];
- // }
- //
- // public final int getCharAttr() {
- // return attr;
- // }
- //
- // public final boolean isAttributePlace() {
- // return attributePlace;
- // }
- //
- // public final void setChar(char c) {
- // isChanged = sChar[0] == c ? false : true;
- // // if (isChanged)
- // // System.out.println(sChar[0] + " - " + c);
- // sChar[0] = c;
- // if (attributePlace)
- // setCharAndAttr(c,32,false);
- //
- // }
- //
- // public final void setUseGUI(int which) {
- //
- // isChanged = whichGui == which ? false : true;
- //
- // whichGui = which;
- // if (which == NO_GUI) {
- // useGui = false;
- // }
- // else {
- // useGui = true;
- // }
- // }
- //
- // public final int getWhichGUI() {
- //
- // return whichGui;
- // }
- //
- //
- // public final void setCharAndAttr(char c, int a, boolean ap) {
- //
- // isChanged = sChar[0] == c ? false : true;
- // // if (isChanged)
- // // System.out.println(sChar[0] + " - " + c);
- //
- // sChar[0] = c;
- // // useGui = false;
- // // whichGui = NO_GUI;
- //
- // if(attr != a)
- // setAttribute(a);
- //
- // if(ap) {
- // attributePlace = true;
- // useGui = false;
- // whichGui = NO_GUI;
- //
- // }
- // else
- // attributePlace = false;
- // }
- //
- // public final void setRowCol(int row, int col) {
- //
- // cArea.setRect((s.fmWidth*col),s.fmHeight * row,s.fmWidth,s.fmHeight);
- // x = s.fmWidth * col;
- // y = s.fmHeight * row;
- // cy = (int)(y + s.fmHeight - (s.lm.getDescent() + s.lm.getLeading()));
- // }
- //
-
public final void disperseAttribute(int pos, int attr) {
- // Screen5250 s = scr;
- //
- // boolean colSep = false;
- // boolean underLine = false;
- // boolean nonDisplay = false;
- // java.awt.Color fg;
- // java.awt.Color bg;
-
char c = 0;
char cs = 0;
--- 575,580 ----
***************
*** 862,868 ****
StringBuffer hsMore = s.getHSMore();
StringBuffer hsBottom = s.getHSBottom();
- // Rectangle2D mArea = new Rectangle2D.Float(0,0,0,0);
- // Rectangle2D mwArea = new Rectangle2D.Float(0,0,0,0);
- // ArrayList mArray = new ArrayList(10);
for (int x = 0; x < lenScreen; x++) {
--- 766,769 ----
***************
*** 1130,1179 ****
}
-
- // int pos = 0;
- //
- // mArea.setRect(0,0,0,0);
- // mwArea.setRect(0,0,0,0);
- // for (int k = 0; k < numCols;k++) {
- //// System.out.println(k);
- // pos =k;
- // boolean gui = false;
- // for (int j=0; j < 19; j++) {
- // if (screen[pos].whichGui != NO_GUI)
- //// System.out.print(screen[pos].getChar());
- //
- // mwArea.setRect(screen[pos].x,
- // screen[pos].y,
- // screen[pos].x,
- // screen[pos].y);
- //
- // if (mArea.getWidth() == 0) {
- // mArea.setRect(mwArea);
- // }
- // else {
- // double x1 = Math.min(mArea.getX(), mwArea.getX());
- // double x2 = Math.max(mArea.getWidth(), mwArea.getWidth());
- // double y1 = Math.min(mArea.getY(), mwArea.getY());
- // double y2 = Math.max(mArea.getHeight(), mwArea.getHeight());
- // mArea.setRect(x1, y1, x2, y2);
- //
- // }
- // pos += numCols;
- // }
- // }
- //
- // if (mwArea.getWidth() != 0) {
- // System.out.println("Mennu area is " +
- // s.getRow(s.getRowColFromPoint((int)mArea.getX(),(int)mArea.getY())) + "," +
- // s.getCol(s.getRowColFromPoint((int)mArea.getX(),(int)mArea.getY())) + "," +
- // s.getRow(s.getRowColFromPoint(
- // (int)mArea.getWidth(),
- // (int)mArea.getHeight())) + "," +
- // s.getCol(s.getRowColFromPoint(
- // (int)mArea.getWidth(),
- // (int)mArea.getHeight()) ));
- // }
-
-
return retHS;
}
--- 1031,1034 ----
***************
*** 1195,1199 ****
screen[sp] == '*') {
hs =false;
- // System.out.println(" hs1 false " + screen[sp].getChar() + " " + sp);
break;
}
--- 1050,1053 ----
***************
*** 1203,1207 ****
os = sp;
while (hs && --os > 0 && screen[os] > ' ' ) {
- // System.out.println(" hs2 length " + (sp-os) + " " + screen[os].getChar());
if (sp - os >= numPref || screen[os] == suff ||
--- 1057,1060 ----
***************
*** 1209,1213 ****
screen[os] == '*') {
hs = false;
- // System.out.println(" hs2 false at " + (sp-os) + " " + screen[os].getChar());
break;
}
--- 1062,1065 ----
***************
*** 1228,1232 ****
screen[sp] == '*') {
hs =false;
- // System.out.println(" hs3 false at " + sp + " " + screen[sp].getChar());
break;
}
--- 1080,1083 ----
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click