KHtml

kjavaprocess.h
1 // -*- c++ -*-
2 
3 /* This file is part of the KDE project
4  *
5  * Copyright (C) 2000 Richard Moore <[email protected]>
6  * 2000 Wynn Wilkes <[email protected]>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef KJAVAPROCESS_H
25 #define KJAVAPROCESS_H
26 
27 #include <QProcess>
28 
29 /**
30  * @short A class for invoking a Java VM
31  *
32  * This class is a general tool for invoking a Java interpreter. It allows you
33  * to specify some of the standard options that should be understood by all
34  * JVMs.
35  *
36  * @author Richard J. Moore, [email protected]
37  * @author Wynn Wilkes, [email protected]
38  */
39 
40 class KJavaProcessPrivate;
41 class KJavaProcess : public QProcess //QObject
42 {
43  Q_OBJECT
44 
45 public:
46  /**
47  * Creates a process object, the process is NOT invoked at this point.
48  * You should first set the process's parameters, and then call startJava.
49  */
50  KJavaProcess(QObject *parent = nullptr);
51  virtual ~KJavaProcess();
52 
53  /**
54  * Invoke the JVM with the parameters that have been set. The Java process
55  * will start after this call.
56  */
57  bool startJava();
58 
59  /**
60  * Stop the JVM (if it's running).
61  */
62  void stopJava();
63 
64  /**
65  * Returns the status of the java Process- true if it's ok, false if it has died.
66  * It calls K3Process::isRunning()
67  */
68  bool isRunning();
69 
70  /**
71  * Used to specify the path to the Java executable to be run.
72  */
73  void setJVMPath(const QString &path);
74 
75  /**
76  * This will set the classpath the Java process will use. It's used as a the
77  * -cp command line option. It adds every jar file stored in $KDEDIRS/share/apps/kjava/
78  * to the classpath, and then adds the $CLASSPATH environmental variable. This allows
79  * users to simply drop the JSSE (Java Secure Sockets Extension classes into that directory
80  * without having to modify the jvm configuration files.
81  */
82  void setClasspath(const QString &classpath);
83 
84  /**
85  * Set a property on the java command line as -Dname=value, or -Dname if value is QString().
86  * For example, you could call setSystemProperty( "kjas.debug", "" ) to set the kjas.debug property.
87  */
88  void setSystemProperty(const QString &name, const QString &value);
89 
90  /**
91  * The class to be called when startJava() is called.
92  */
93  void setMainClass(const QString &clazzName);
94 
95  /**
96  * Extra flags passed to the JVM.
97  */
98  void setExtraArgs(const QString &args);
99 
100  /**
101  * Arguments passed to the main class. They will be very last in the java
102  * command line, after the main class.
103  */
104  void setClassArgs(const QString &classArgs);
105 
106  /**
107  * Sends a command to the KJAS Applet Server by building a QByteArray
108  * out of the data, and then writes it standard out.
109  */
110  void send(char cmd_code, const QStringList &args);
111 
112  /**
113  * Sends a command to the KJAS Applet Server by building a QByteArray
114  * out of the data, and then writes it standard out. It adds each QString
115  * in the arg list, and then adds the data array.
116  */
117  void send(char cmd_code, const QStringList &args, const QByteArray &data);
118 
119  /**
120  * Writes all pending data to JVM
121  **/
122  void flushBuffers();
123 
124 protected Q_SLOTS:
125  /**
126  * This slot is called when the Java Process writes to standard out. We then
127  * process the data from the file descriptor that is passed to us and send the
128  * command to the AppletServer
129  */
130  void slotReceivedData();
131  /**
132  * This slot is called when the Java Process exited.
133  */
134  void slotExited();
135 
136 protected:
137  virtual bool invokeJVM();
138  virtual void killJVM();
139 
140  QByteArray addArgs(char cmd_code, const QStringList &args);
141  void storeSize(QByteArray *buff);
142 
143 Q_SIGNALS:
144  void received(const QByteArray &);
145  void exited(int status);
146 
147 private:
148  KJavaProcessPrivate *const d;
149 
150 };
151 
152 #endif // KJAVAPROCESS_H
Q_SIGNALSQ_SIGNALS
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.