Exemplo n.º 1
1
  public void bootOptionsReceived(BootEvent bootEvent) {
    log.info(" boot options received " + bootEvent.getNewSessionOptions());

    // reload setting, to ensure correct bootstraps
    ConfigureFactory.getInstance().reloadSettings();

    // If the options are not equal to the string 'null' then we have boot options
    if (!bootEvent.getNewSessionOptions().equals("null")) {
      // check if a session parameter is specified on the command line
      String[] args = new String[TN5250jConstants.NUM_PARMS];
      parseArgs(bootEvent.getNewSessionOptions(), args);

      if (isSpecified("-s", args)) {

        String sd = getParm("-s", args);
        if (sessions.containsKey(sd)) {
          parseArgs(sessions.getProperty(sd), args);
          final String[] args2 = args;
          final String sd2 = sd;
          SwingUtilities.invokeLater(() -> newSession(sd2, args2));
        }
      } else {

        if (args[0].startsWith("-")) {
          SwingUtilities.invokeLater(() -> startNewSession());
        } else {
          final String[] args2 = args;
          final String sd2 = args[0];
          SwingUtilities.invokeLater(() -> newSession(sd2, args2));
        }
      }
    } else {
      SwingUtilities.invokeLater(() -> startNewSession());
    }
  }
Exemplo n.º 2
0
 /** Initialize the applet */
 public void init() {
   try {
     jbInit();
   } catch (Exception e) {
     if (log == null) System.out.println(e.getMessage());
     else log.warn("In constructor: ", e);
   }
 }
Exemplo n.º 3
0
  /** Tests if a parameter was specified or not. */
  private boolean isSpecified(String parm) {

    if (getParameter(parm) != null) {
      log.info("Parameter " + parm + " is specified as: " + getParameter(parm));
      return true;
    }
    return false;
  }
Exemplo n.º 4
0
  protected void closingDown(TerminalViewInterface view) {

    Sessions sess = manager.getSessions();

    if (log.isDebugEnabled()) {
      log.debug("number of active sessions is " + sess.getCount());
    }

    if (viewNamesForNextStartBuilder == null) {
      // preserve sessions for next boot
      viewNamesForNextStartBuilder = new StringBuilder();
    }
    while (view.getSessionViewCount() > 0) {
      SessionPanel sesspanel = view.getSessionAt(0);
      viewNamesForNextStartBuilder.append("-s ").append(sesspanel.getSessionName()).append(" ");
      closeSessionInternal(sesspanel);
    }

    sessions.setProperty(
        "emul.frame" + view.getFrameSequence(),
        view.getX() + "," + view.getY() + "," + view.getWidth() + "," + view.getHeight());

    frames.remove(view);
    view.dispose();

    log.debug("number of active sessions we have after shutting down " + sess.getCount());

    log.info("view settings " + viewNamesForNextStartBuilder);
    if (sess.getCount() == 0) {

      sessions.setProperty("emul.width", Integer.toString(view.getWidth()));
      sessions.setProperty("emul.height", Integer.toString(view.getHeight()));
      sessions.setProperty("emul.view", viewNamesForNextStartBuilder.toString());

      // save off the session settings before closing down
      ConfigureFactory.getInstance()
          .saveSettings(
              ConfigureFactory.SESSIONS, ConfigureFactory.SESSIONS, "------ Defaults --------");
      if (controller != null) {
        controller.interrupt();
      }
      System.exit(0);
    }
  }
Exemplo n.º 5
0
  private static final void writeToFile(String sc, File file) {

    FileOutputStream out = null;
    try {
      out = new FileOutputStream(file);
      out.write(sc.getBytes());
      out.flush();
      out.close();

    } catch (FileNotFoundException fnfe) {
      LOG.warn("fnfe: " + fnfe.getMessage());
    } catch (IOException ioe) {
      LOG.warn("ioe: " + ioe.getMessage());
    } finally {
      if (out != null)
        try {
          out.close();
        } catch (IOException exc) {
          LOG.warn("ioe finally: " + exc.getMessage());
        }
    }
  }
Exemplo n.º 6
0
  /**
   * Recursively read the scripts directory and add them to our macros vector holding area
   *
   * @param vector
   * @param path
   * @param directory
   * @param session
   */
  private static void loadScripts(
      Vector vector, String path, File directory, SessionPanel session) {

    ExecuteScriptAction action;

    File[] macroFiles = directory.listFiles();
    if (macroFiles == null || macroFiles.length == 0) return;

    Arrays.sort(macroFiles, new MacroCompare());

    // KJP - We will wrap this in a try catch block to catch security
    // exceptions
    for (int i = 0; i < macroFiles.length; i++) {
      try {
        File file = macroFiles[i];
        String fileName = file.getName();
        if (file.isHidden()) {
          /* do nothing! */
          continue;
        } else if (file.isDirectory()) {
          Vector submenu = new Vector();
          submenu.addElement(fileName.replace('_', ' '));
          loadScripts(submenu, path + fileName + '/', file, session);
          // if we do not want empty directories to show up uncomment
          // this line.
          // if(submenu.size() != 1)
          vector.addElement(submenu);
        } else {
          if (InterpreterDriverManager.isScriptSupported(fileName)) {
            String fn = fileName.replace('_', ' ');
            int index = fn.lastIndexOf('.');
            if (index > 0) {
              fn = fn.substring(0, index);
            }
            action =
                new ExecuteScriptAction(fn, file.getAbsolutePath(), session) {

                  private static final long serialVersionUID = 1L;
                };
            vector.addElement(action);
          }
        }
      } catch (SecurityException se) {
        log.warn(se.getMessage());
      }
    }
  }
Exemplo n.º 7
0
  /** Component initialization */
  private void jbInit() throws Exception {
    this.setSize(new Dimension(400, 300));

    if (isSpecified("-L")) LangTool.init(parseLocale(getParameter("-L")));
    else LangTool.init();

    // Let's check some permissions
    try {
      System.getProperty(".java.policy");
    } catch (SecurityException e) {
      e.printStackTrace();
      TN5250jSecurityAccessDialog.showErrorMessage(e);
      return;
    }
    log = TN5250jLogFactory.getLogger(this.getClass());

    Properties sesProps = new Properties();
    log.info(" We have loaded a new one");

    // Start loading properties - Host must exist
    sesProps.put(TN5250jConstants.SESSION_HOST, getParameter("host"));

    if (isSpecified("-e")) sesProps.put(TN5250jConstants.SESSION_TN_ENHANCED, "1");

    if (isSpecified("-p")) {
      sesProps.put(TN5250jConstants.SESSION_HOST_PORT, getParameter("-p"));
    }

    //      if (isSpecified("-f",args))
    //         propFileName = getParm("-f",args);

    if (isSpecified("-cp")) sesProps.put(TN5250jConstants.SESSION_CODE_PAGE, getParameter("-cp"));

    if (isSpecified("-gui")) sesProps.put(TN5250jConstants.SESSION_USE_GUI, "1");

    if (isSpecified("-t")) sesProps.put(TN5250jConstants.SESSION_TERM_NAME_SYSTEM, "1");

    if (isSpecified("-132"))
      sesProps.put(TN5250jConstants.SESSION_SCREEN_SIZE, TN5250jConstants.SCREEN_SIZE_27X132_STR);
    else sesProps.put(TN5250jConstants.SESSION_SCREEN_SIZE, TN5250jConstants.SCREEN_SIZE_24X80_STR);

    // socks proxy host argument
    if (isSpecified("-sph")) {
      sesProps.put(TN5250jConstants.SESSION_PROXY_HOST, getParameter("-sph"));
    }

    // socks proxy port argument
    if (isSpecified("-spp"))
      sesProps.put(TN5250jConstants.SESSION_PROXY_PORT, getParameter("-spp"));

    // check if device name is specified
    if (isSpecified("-dn")) sesProps.put(TN5250jConstants.SESSION_DEVICE_NAME, getParameter("-dn"));
    // are we to use a ssl and if we are what type

    if (isSpecified("-sslType")) {

      sesProps.put(TN5250jConstants.SSL_TYPE, getParameter("-sslType"));
    }

    loadSystemProperty("SESSION_CONNECT_USER");
    loadSystemProperty("SESSION_CONNECT_PASSWORD");
    loadSystemProperty("SESSION_CONNECT_PROGRAM");
    loadSystemProperty("SESSION_CONNECT_LIBRARY");
    loadSystemProperty("SESSION_CONNECT_MENU");

    manager = SessionManager.instance();
    final Session5250 s = manager.openSession(sesProps, "", "Test Applet");
    final SessionPanel gui = new SessionPanel(s);
    //      final JTerminal jt = new JTerminal(s);

    this.getContentPane().add(gui);

    s.connect();
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            //            jt.grabFocus();
            gui.grabFocus();
          }
        });
  }