3 /* This file is part of the KDE project
5 * Copyright (C) 2000 Richard Moore <rich@kde.org>
6 * 2000 Wynn Wilkes <wynnw@caldera.com>
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.
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.
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.
24 #ifndef KJAVAAPPLETSERVER_H
25 #define KJAVAAPPLETSERVER_H
27 #include "kjavaprocess.h"
28 #include <QtCore/QObject>
29 #include <QtCore/QMap>
30 #include <QtCore/QSize>
33 * @short Communicates with a KJAS server to display and control Java applets.
35 * @author Richard J. Moore, rich@kde.org
38 class KJavaAppletContext
;
39 class KJavaAppletServerPrivate
;
42 class KJavaAppletServer
: public QObject
48 * Create the applet server. These shouldn't be used directly,
49 * use allocateJavaServer instead
55 * A factory method that returns the default server. This is the way this
56 * class is usually instantiated.
58 static KJavaAppletServer
*allocateJavaServer();
61 * When you are done using your reference to the AppletServer, you must
62 * dereference it by calling freeJavaServer().
64 static void freeJavaServer();
67 * This allows the KJavaAppletWidget to display some feedback in a QLabel
68 * while the applet is being loaded. If the java process could not be
69 * started, an error message is displayed instead.
71 static QString
getAppletLabel();
74 * Create an applet context with the specified id.
76 void createContext( int contextId
, KJavaAppletContext
* context
);
79 * Destroy the applet context with the specified id. All the applets in the
80 * context will be destroyed as well.
82 void destroyContext( int contextId
);
85 * Create an applet in the specified context with the specified id. The applet
86 * name, class etc. are specified in the same way as in the HTML APPLET tag.
88 bool createApplet( int contextId
, int appletId
,
89 const QString
& name
, const QString
& clazzName
,
90 const QString
& baseURL
, const QString
& user
,
91 const QString
& password
, const QString
& authname
,
92 const QString
& codeBase
, const QString
& jarFile
,
93 QSize size
, const QMap
<QString
, QString
>& params
,
94 const QString
& windowTitle
);
97 * This should be called by the KJavaAppletWidget
99 void initApplet( int contextId
, int appletId
);
102 * Destroy an applet in the specified context with the specified id.
104 void destroyApplet( int contextId
, int appletId
);
107 * Start the specified applet.
109 void startApplet( int contextId
, int appletId
);
112 * Stop the specified applet.
114 void stopApplet( int contextId
, int appletId
);
122 * Send data we got back from a KJavaDownloader back to the appropriate
125 void sendURLData( int loaderID
, int code
, const QByteArray
& data
);
127 * Removes KJavaDownloader from the list (deletes it too).
129 void removeDataJob( int loaderID
);
132 * Shut down the KJAS server.
135 KJavaProcess
* javaProcess() { return process
; }
137 QString
appletLabel();
139 void waitForReturnData(JSStackFrame
*);
140 void endWaitForReturnData();
142 bool getMember(QStringList
& args
, QStringList
& ret_args
);
143 bool putMember(QStringList
& args
);
144 bool callMember(QStringList
& args
, QStringList
& ret_args
);
145 void derefObject(QStringList
& args
);
149 void setupJava( KJavaProcess
* p
);
151 KJavaProcess
* process
;
154 void slotJavaRequest( const QByteArray
& qb
);
155 void checkShutdown();
156 void timerEvent(QTimerEvent
*);
160 KJavaAppletServerPrivate
* const d
;
165 class PermissionDialog
: public QObject
169 PermissionDialog( QWidget
* );
172 QString
exec( const QString
& cert
, const QString
& perm
);
181 #endif // KJAVAAPPLETSERVER_H