1 /*
2 * SSHTools - Java SSH2 API
3 *
4 * Copyright (C) 2002-2003 Lee David Painter and Contributors.
5 *
6 * Contributions made by:
7 *
8 * Brett Smith
9 * Richard Pernavas
10 * Erwin Bolwidt
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 */
26 package com.sshtools.daemon.session;
27
28 import com.sshtools.daemon.terminal;
29
30 import java.io;
31
32
33 /**
34 *
35 *
36 * @author $author$
37 * @version $Revision: 1.12 $
38 */
39 public class PseudoTerminalWrapper {
40 private InputStream masterIn;
41 private OutputStream masterOut;
42 private InputStream slaveIn;
43 private OutputStream slaveOut;
44 private String term;
45 private int cols;
46 private int rows;
47 private int width;
48 private int height;
49 private String modes;
50 private TerminalIO terminal;
51 private UserInput ui;
52
53 /**
54 * Creates a new PseudoTerminalWrapper object.
55 *
56 * @param term
57 * @param cols
58 * @param rows
59 * @param width
60 * @param height
61 * @param modes
62 */
63 public PseudoTerminalWrapper(String term, int cols, int rows, int width,
64 int height, String modes) {
65 this.term = term;
66 this.cols = cols;
67 this.rows = rows;
68 this.height = height;
69 this.width = width;
70 }
71
72 /**
73 *
74 *
75 * @param masterIn
76 */
77 public void bindMasterInputStream(InputStream masterIn) {
78 this.masterIn = masterIn;
79 }
80
81 /**
82 *
83 *
84 * @param masterOut
85 */
86 public void bindMasterOutputStream(OutputStream masterOut) {
87 this.masterOut = masterOut;
88 }
89
90 /**
91 *
92 *
93 * @param slaveOut
94 */
95 public void bindSlaveOutputStream(OutputStream slaveOut) {
96 this.slaveOut = slaveOut;
97 }
98
99 /**
100 *
101 *
102 * @param slaveIn
103 */
104 public void bindSlaveInputStream(InputStream slaveIn) {
105 this.slaveIn = slaveIn;
106 }
107
108 /**
109 *
110 *
111 * @throws IOException
112 */
113 public void initialize() throws IOException {
114 this.terminal = new TerminalIO(masterIn, masterOut, term, cols, 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 }