001: /*
002: * SSHTools - Java SSH2 API
003: *
004: * Copyright (C) 2002-2003 Lee David Painter and Contributors.
005: *
006: * Contributions made by:
007: *
008: * Brett Smith
009: * Richard Pernavas
010: * Erwin Bolwidt
011: *
012: * This program is free software; you can redistribute it and/or
013: * modify it under the terms of the GNU General Public License
014: * as published by the Free Software Foundation; either version 2
015: * of the License, or (at your option) any later version.
016: *
017: * This program is distributed in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021: *
022: * You should have received a copy of the GNU General Public License
023: * along with this program; if not, write to the Free Software
024: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
025: */
026: package com.sshtools.daemon.session;
027:
028: import com.sshtools.daemon.terminal.*;
029:
030: import java.io.*;
031:
032: /**
033: *
034: *
035: * @author $author$
036: * @version $Revision: 1.12 $
037: */
038: public class PseudoTerminalWrapper {
039: private InputStream masterIn;
040: private OutputStream masterOut;
041: private InputStream slaveIn;
042: private OutputStream slaveOut;
043: private String term;
044: private int cols;
045: private int rows;
046: private int width;
047: private int height;
048: private String modes;
049: private TerminalIO terminal;
050: private UserInput ui;
051:
052: /**
053: * Creates a new PseudoTerminalWrapper object.
054: *
055: * @param term
056: * @param cols
057: * @param rows
058: * @param width
059: * @param height
060: * @param modes
061: */
062: public PseudoTerminalWrapper(String term, int cols, int rows,
063: int width, int height, String modes) {
064: this .term = term;
065: this .cols = cols;
066: this .rows = rows;
067: this .height = height;
068: this .width = width;
069: }
070:
071: /**
072: *
073: *
074: * @param masterIn
075: */
076: public void bindMasterInputStream(InputStream masterIn) {
077: this .masterIn = masterIn;
078: }
079:
080: /**
081: *
082: *
083: * @param masterOut
084: */
085: public void bindMasterOutputStream(OutputStream masterOut) {
086: this .masterOut = masterOut;
087: }
088:
089: /**
090: *
091: *
092: * @param slaveOut
093: */
094: public void bindSlaveOutputStream(OutputStream slaveOut) {
095: this .slaveOut = slaveOut;
096: }
097:
098: /**
099: *
100: *
101: * @param slaveIn
102: */
103: public void bindSlaveInputStream(InputStream slaveIn) {
104: this .slaveIn = slaveIn;
105: }
106:
107: /**
108: *
109: *
110: * @throws IOException
111: */
112: public void initialize() throws IOException {
113: this .terminal = new TerminalIO(masterIn, masterOut, term, cols,
114: rows);
115: terminal.bindSlaveInputStream(slaveIn);
116: terminal.bindSlaveOutputStream(slaveOut);
117: ui = new UserInput(terminal, slaveOut);
118: }
119:
120: /**
121: *
122: *
123: * @return
124: */
125: public InputStream getMasterInputStream() {
126: return terminal.getMasterInputStream();
127: }
128: }
|