summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/org/kde/koala/KProcIO.java
blob: 8b69d198bb644b6ab7c58897a9a6794d120440da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//Auto-generated by kalyptus. DO NOT EDIT.
package org.kde.koala;

import org.kde.qt.Qt;
import org.kde.qt.TQMetaObject;
import org.kde.qt.QtSupport;
import org.kde.qt.TQTextCodec;

/**

 KProcIO
 This class provides a slightly simpler interface to the communication
  functions provided by KProcess.  The simplifications are:

	<li>
	The buffer for a write is copied to an internal KProcIO
	        buffer and maintained/freed appropriately.  There is no need
	        to be concerned with wroteStdin() signals _at_all_.
	</li>
	
	<li>
	readln() reads a line of data and buffers any leftovers.
	</li>
	
	<li>
	Conversion from/to unicode.
	</li>
	 Basically, KProcIO gives you buffered I/O similar to fgets()/fputs().
 Aside from these, and the fact that start() takes different
 parameters, use this class just like KProcess.
 See {@link KProcIOSignals} for signals emitted by KProcIO
		@author David Sweet

		@short A slightly simpler interface to KProcess.

*/
public class KProcIO extends KProcess  {
	protected KProcIO(Class dummy){super((Class) null);}
	public native TQMetaObject metaObject();
	public native String className();
	/**	
		 Constructor
		   		@short    Constructor
	*/
	public KProcIO(TQTextCodec codec) {
		super((Class) null);
		newKProcIO(codec);
	}
	private native void newKProcIO(TQTextCodec codec);
	public KProcIO() {
		super((Class) null);
		newKProcIO();
	}
	private native void newKProcIO();
	/**	
		 Sets the communication mode to be passed to KProcess.start()
		 by start(). The default communication mode is KProcess.All.
		 You probably want to use this function in conjunction with
		 KProcess.setUsePty().
			@param comm the communication mode
		   		@short    Sets the communication mode to be passed to KProcess.start()  by start().
	*/
	public native void setComm(int comm);
	/**	
		  Starts the process. It will fail in the following cases:
		
			<li>
			The process is already running.
			</li>
			
			<li>
			The command line argument list is empty.
			</li>
			
			<li>
			The starting of the process failed (could not fork).
			</li>
			
			<li>
			The executable was not found.
			</li>
				@param runmode For a detailed description of the
		  various run modes, have a look at the
		  general description of the KProcess class.
			@param includeStderr If true, data from both stdout and stderr is
		  listened to. If false, only stdout is listened to.
				@return true on success, false on error.

		@short     Starts the process.
	*/
	public native boolean start(int runmode, boolean includeStderr);
	public native boolean start(int runmode);
	public native boolean start();
	/**	
		 Writes text to stdin of the process.
			@param line Text to write.
			@param appendnewline if true, a newline '\\n' is appended.
				@return true if successful, false otherwise

		@short    Writes text to stdin of the process.
	*/
	public native boolean writeStdin(String line, boolean appendnewline);
	public native boolean writeStdin(String line);
	/**	
		 Writes data to stdin of the process.
			@param data Data to write.
				@return true if successful, false otherwise

		@short    Writes data to stdin of the process.
	*/
	public native boolean writeStdin(byte[] data);
	/**	
		 Closes stdin after all data has been send.
		   		@short    Closes stdin after all data has been send.
	*/
	public native void closeWhenDone();
	/**	
		 Reads a line of text (up to and including '\\n').
			 Use readln() in response to a readReady() signal.
		 You may use it multiple times if more than one line of data is
		  available.
		 Be sure to use ackRead() when you have finished processing the
		  readReady() signal.  This informs KProcIO that you are ready for
		  another readReady() signal.
			 readln() never blocks.
			 autoAck==true makes these functions call ackRead() for you.
			@param line is used to store the line that was read.
			@param autoAck when true, ackRead() is called for you.
			@param partial when provided the line is returned
		 even if it does not contain a '\\n'. partial will be set to
		 false if the line contains a '\\n' and false otherwise.
				@return the number of characters read, or -1 if no data is available.

		@short    Reads a line of text (up to and including '\\n').
	*/
	public native int readln(StringBuffer line, boolean autoAck, boolean[] partial);
	public native int readln(StringBuffer line, boolean autoAck);
	public native int readln(StringBuffer line);
	/**	
		 Reset the class.  Doesn't kill the process.
				@short    Reset the class.
	*/
	public native void resetAll();
	/**	
		 Call this after you have finished processing a readReady()
		 signal.  This call need not be made in the slot that was signalled
		 by readReady().  You won't receive any more readReady() signals
		 until you acknowledge with ackRead().  This prevents your slot
		 from being reentered while you are still processing the current
		 data.  If this doesn't matter, then call ackRead() right away in
		 your readReady()-processing slot.
				@short    Call this after you have finished processing a readReady()  signal.
	*/
	public native void ackRead();
	/**	
		  Turns readReady() signals on and off.
		   You can turn this off at will and not worry about losing any data.
		   (as long as you turn it back on at some point...)
			@param enable true to turn the signals on, false to turn them off
		   		@short     Turns readReady() signals on and off.
	*/
	public native void enableReadSignals(boolean enable);
	protected native void controlledEmission();
	protected native void received(KProcess proc, String buffer, int buflen);
	protected native void sent(KProcess arg1);
	/** Deletes the wrapped C++ instance */
	protected native void finalize() throws InternalError;
	/** Delete the wrapped C++ instance ahead of finalize() */
	public native void dispose();
	/** Has the wrapped C++ instance been deleted? */
	public native boolean isDisposed();
}