You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
4.9 KiB
163 lines
4.9 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
*
|
||
|
* Copyright (C) 2000 Richard Moore <rich@kde.org>
|
||
|
* 2000 Wynn Wilkes <wynnw@caldera.com>
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library 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
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef KJAVAPROCESS_H
|
||
|
#define KJAVAPROCESS_H
|
||
|
|
||
|
#include <kprocess.h>
|
||
15 years ago
|
#include <tqcstring.h>
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @short A class for invoking a Java VM
|
||
|
*
|
||
|
* This class is a general tool for invoking a Java interpreter. It allows you
|
||
|
* to specify some of the standard options that should be understood by all
|
||
|
* JVMs.
|
||
|
*
|
||
|
* @author Richard J. Moore, rich@kde.org
|
||
|
* @author Wynn Wilkes, wynnw@calderasystems.com
|
||
|
*/
|
||
|
|
||
|
class KJavaProcessPrivate;
|
||
12 years ago
|
class KJavaProcess : public TDEProcess //QObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
/**
|
||
|
* Creates a process object, the process is NOT invoked at this point.
|
||
|
* You should first set the process's parameters, and then call startJava.
|
||
|
*/
|
||
|
KJavaProcess();
|
||
|
virtual ~KJavaProcess();
|
||
|
|
||
|
/**
|
||
|
* Invoke the JVM with the parameters that have been set. The Java process
|
||
|
* will start after this call.
|
||
|
*/
|
||
|
bool startJava();
|
||
|
|
||
|
/**
|
||
|
* Stop the JVM (if it's running).
|
||
|
*/
|
||
|
void stopJava();
|
||
|
|
||
|
/**
|
||
|
* Returns the status of the java Process- true if it's ok, false if it has died.
|
||
12 years ago
|
* It calls TDEProcess::isRunning()
|
||
15 years ago
|
*/
|
||
|
bool isRunning();
|
||
|
|
||
|
/**
|
||
|
* Used to specify the path to the Java executable to be run.
|
||
|
*/
|
||
15 years ago
|
void setJVMPath( const TQString& path );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* This will set the classpath the Java process will use. It's used as a the
|
||
13 years ago
|
* -cp command line option. It adds every jar file stored in $TDEDIRS/share/apps/kjava/
|
||
15 years ago
|
* to the classpath, and then adds the $CLASSPATH environmental variable. This allows
|
||
|
* users to simply drop the JSSE (Java Secure Sockets Extension classes into that directory
|
||
|
* without having to modify the jvm configuration files.
|
||
|
*/
|
||
15 years ago
|
void setClasspath( const TQString& classpath );
|
||
15 years ago
|
|
||
|
/**
|
||
15 years ago
|
* Set a property on the java command line as -Dname=value, or -Dname if value is TQString::null.
|
||
15 years ago
|
* For example, you could call setSystemProperty( "kjas.debug", "" ) to set the kjas.debug property.
|
||
|
*/
|
||
15 years ago
|
void setSystemProperty( const TQString& name, const TQString& value );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* The class to be called when startJava() is called.
|
||
|
*/
|
||
15 years ago
|
void setMainClass( const TQString& clazzName );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Extra flags passed to the JVM.
|
||
|
*/
|
||
15 years ago
|
void setExtraArgs( const TQString& args );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Arguments passed to the main class. They will be very last in the java
|
||
|
* command line, after the main class.
|
||
|
*/
|
||
15 years ago
|
void setClassArgs( const TQString& classArgs );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Sends a command to the KJAS Applet Server by building a QByteArray
|
||
|
* out of the data, and then writes it standard out.
|
||
|
*/
|
||
15 years ago
|
void send( char cmd_code, const TQStringList& args );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Sends a command to the KJAS Applet Server by building a QByteArray
|
||
|
* out of the data, and then writes it standard out. It adds each QString
|
||
|
* in the arg list, and then adds the data array.
|
||
|
*/
|
||
15 years ago
|
void send( char cmd_code, const TQStringList& args, const TQByteArray& data );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Writes all pending data to JVM
|
||
|
**/
|
||
|
void flushBuffers();
|
||
|
|
||
|
protected slots:
|
||
|
/**
|
||
|
* This slot is called whenever something is written to stdin of the process.
|
||
14 years ago
|
* It's called again to make sure we keep emptying out the buffer that contains
|
||
15 years ago
|
* the messages we need send.
|
||
|
*/
|
||
|
void slotWroteData();
|
||
|
|
||
|
/**
|
||
|
* This slot is called when the Java Process writes to standard out. We then
|
||
|
* process the data from the file descriptor that is passed to us and send the
|
||
|
* command to the AppletServer
|
||
|
*/
|
||
|
void slotReceivedData( int, int& );
|
||
|
/**
|
||
|
* This slot is called when the Java Process exited.
|
||
|
*/
|
||
12 years ago
|
void slotExited( TDEProcess *process );
|
||
15 years ago
|
|
||
|
protected:
|
||
|
virtual bool invokeJVM();
|
||
|
virtual void killJVM();
|
||
|
|
||
15 years ago
|
TQByteArray* addArgs( char cmd_code, const TQStringList& args );
|
||
15 years ago
|
void popBuffer();
|
||
15 years ago
|
void sendBuffer( TQByteArray* buff );
|
||
|
void storeSize( TQByteArray* buff );
|
||
15 years ago
|
|
||
12 years ago
|
TDEProcess* javaProcess;
|
||
15 years ago
|
|
||
|
signals:
|
||
15 years ago
|
void received( const TQByteArray& );
|
||
15 years ago
|
void exited( int status );
|
||
|
|
||
|
private:
|
||
|
KJavaProcessPrivate *d;
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif // KJAVAPROCESS_H
|