tn5250j/src/org/tn5250j SessionGUI.java,NONE,1.1 SessionManager.java,1.8,1.9

"Kenneth J. Pouncey" <[email protected]> Thu, 22 Jul 2004 04:54:59 +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-serv4438/src/org/tn5250j

Modified Files:
	SessionManager.java 
Added Files:
	SessionGUI.java 
Log Message:
Updates for headless

--- NEW FILE: SessionGUI.java ---
/*
 * @(#)SessionGUI.java
 * Copyright:    Copyright (c) 2001 - 2004
 * @author Kenneth J. Pouncey
 *
 * 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 GUI session
 */
public class SessionGUI extends Gui5250 implements TN5250jConstants {

   private String configurationResource;
   private String sessionName;
   private boolean connected;
   private int sessionType;
   private Properties sesProps;
   private Vector listeners;
   private SessionChangeEvent sce;
   private String sslType;
   private boolean firstScreen;
   private char[] signonSave;


   public SessionGUI (Session5250 session) {
      super(session);

      this.configurationResource = session.getConfigurationResource();
      this.sessionName = session.getSessionName();
      sesProps = session.sesProps;
      sce = new SessionChangeEvent(this);

      session.getConfiguration().addSessionConfigListener(this);

   }

   public Session5250 getSession() {
      return super.session;
   }

   public void setSession(Session5250 session) {
      this.session = session;
   }


   public boolean isConnected() {

      return session.getVT().isConnected();

   }

   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 (session.getVT() != null)
         return session.getVT().getAllocatedDeviceName();
      else
         return null;
   }

   public int getSessionType() {

      return sessionType;

   }

   public String getHostName() {
      return session.getVT().getHostName();
   }

   public Screen5250 getScreen() {

      return screen;

   }


   public void connect() {

      session.connect();
   }

   public void disconnect() {

      session.disconnect();
   }

   /**
    * Add a SessionListener to the listener list.
    *
    * @param listener  The SessionListener to be added
    */
   public synchronized void addSessionListener(SessionListener listener) {

      session.addSessionListener(listener);

   }

   /**
    * Remove a SessionListener from the listener list.
    *
    * @param listener  The SessionListener to be removed
    */
   public synchronized void removeSessionListener(SessionListener listener) {
      session.removeSessionListener(listener);

   }

}
Index: SessionManager.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/SessionManager.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** SessionManager.java	30 Jun 2004 06:18:56 -0000	1.8
--- SessionManager.java	22 Jul 2004 04:54:56 -0000	1.9
***************
*** 34,38 ****
     static private Sessions sessions;
     static private Vector configs;
!    
     private TN5250jLogger log = TN5250jLogFactory.getLogger (this.getClass());
     /**
--- 34,38 ----
     static private Sessions sessions;
     static private Vector configs;
! 
     private TN5250jLogger log = TN5250jLogFactory.getLogger (this.getClass());
     /**
***************
*** 79,83 ****
     public void closeSession(String sessionName) {
  
!       Session session = (Session)sessions.item(sessionName);
        if (session != null)
           closeSession(session);
--- 79,83 ----
     public void closeSession(String sessionName) {
  
!       SessionGUI session = ((Session5250)sessions.item(sessionName)).getGUI();
        if (session != null)
           closeSession(session);
***************
*** 85,96 ****
     }
  
!    public void closeSession(Session sessionObject) {
  
        sessionObject.closeDown();
!       sessions.removeSession((Session)sessionObject);
  
     }
  
!    public Session openSession(Properties sesProps, String configurationResource
                                                  , String sessionName) {
  //                                             throws TN5250jException {
--- 85,96 ----
     }
  
!    public void closeSession(SessionGUI sessionObject) {
  
        sessionObject.closeDown();
!       sessions.removeSession(((SessionGUI)sessionObject).getSession());
  
     }
  
!    public Session5250 openSession(Properties sesProps, String configurationResource
                                                  , String sessionName) {
  //                                             throws TN5250jException {
***************
*** 124,134 ****
        }
  
!       Session newSession = new Session(sesProps,configurationResource,
                                            sessionName,useConfig);
        sessions.addSession(newSession);
-       useConfig.addSessionConfigListener(newSession);
        return newSession;
  
     }
- 
  }
\ No newline at end of file
--- 124,132 ----
        }
  
!       Session5250 newSession = new Session5250(sesProps,configurationResource,
                                            sessionName,useConfig);
        sessions.addSession(newSession);
        return newSession;
  
     }
  }
\ No newline at end of file



-------------------------------------------------------
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