summaryrefslogtreecommitdiffstats
path: root/khtml/java/kjavaappletserver.h
blob: 63463b0404ff1535e05bcabdd0ae92f8838cdde8 (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
173
174
175
176
177
178
179
180
// -*- c++ -*-

/* This file is part of the KDE project
 *
 * Copyright (C) 2000 Richard Moore <[email protected]>
 *               2000 Wynn Wilkes <[email protected]>
 *
 * 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 KJAVAAPPLETSERVER_H
#define KJAVAAPPLETSERVER_H

#include "kjavaprocess.h"
#include <tqobject.h>
#include <tqmap.h>


/**
 * @short Communicates with a KJAS server to display and control Java applets.
 *
 * @author Richard J. Moore, [email protected]
 */

class KJavaAppletContext;
class KJavaAppletServerPrivate;
class JSStackFrame;

class KJavaAppletServer : public TQObject
{
Q_OBJECT

public:
    /**
     * Create the applet server.  These shouldn't be used directly,
     * use allocateJavaServer instead
     */
    KJavaAppletServer();
    ~KJavaAppletServer();

    /**
     * A factory method that returns the default server. This is the way this
     * class is usually instantiated.
     */
    static KJavaAppletServer *allocateJavaServer();

    /**
     * When you are done using your reference to the AppletServer,  you must
     * dereference it by calling freeJavaServer().
     */
    static void freeJavaServer();

    /**
     * This allows the KJavaAppletWidget to display some feedback in a QLabel
     * while the applet is being loaded.  If the java process could not be
     * started, an error message is displayed instead.
     */
    static TQString getAppletLabel();

    /**
     * Create an applet context with the specified id.
     */
    void createContext( int contextId, KJavaAppletContext* context );

    /**
     * Destroy the applet context with the specified id. All the applets in the
     * context will be destroyed as well.
     */
    void destroyContext( int contextId );

    /**
     * Create an applet in the specified context with the specified id. The applet
     * name, class etc. are specified in the same way as in the HTML APPLET tag.
     */
    bool createApplet( int contextId, int appletId,
                       const TQString & name, const TQString & clazzName,
                       const TQString & baseURL, const TQString & user,
                       const TQString & password, const TQString & authname,
                       const TQString & codeBase, const TQString & jarFile,
                       TQSize size, const TQMap<TQString, TQString>& params,
                       const TQString & windowTitle );

    /**
     * This should be called by the KJavaAppletWidget
     */
    void initApplet( int contextId, int appletId );

    /**
     * Destroy an applet in the specified context with the specified id.
     */
    void destroyApplet( int contextId, int appletId );

    /**
     * Start the specified applet.
     */
    void startApplet( int contextId, int appletId );

    /**
     * Stop the specified applet.
     */
    void stopApplet( int contextId, int appletId );

    /**
     * Show java console.
     */
    void showConsole();

    /**
     * Send data we got back from a KJavaDownloader back to the appropriate
     * class loader.
     */
    void sendURLData( int loaderID, int code, const TQByteArray& data );
    /**
     * Removes KJavaDownloader from the list (deletes it too).
     */
    void removeDataJob( int loaderID );

    /**
     * Shut down the KJAS server.
     */
    void quit();
    KJavaProcess* javaProcess() { return process; }

    TQString appletLabel();

    void waitForReturnData(JSStackFrame *);
    void endWaitForReturnData();

    bool getMember(TQStringList & args, TQStringList & ret_args);
    bool putMember(TQStringList & args);
    bool callMember(TQStringList & args, TQStringList & ret_args);
    void derefObject(TQStringList & args);

    bool usingKIO();
protected:
    void setupJava( KJavaProcess* p );

    KJavaProcess* process;

protected slots:
    void slotJavaRequest( const TQByteArray& qb );
    void checkShutdown();
    void timerEvent(TQTimerEvent *);

private:
    KJavaAppletServerPrivate* d;

};


class PermissionDialog : public TQObject
{
    Q_OBJECT
public:
    PermissionDialog( TQWidget* );
    ~PermissionDialog();

    TQCString exec( const TQString & cert, const TQString & perm );

private slots:
     void clicked();

private:
    TQCString m_button;
};

#endif // KJAVAAPPLETSERVER_H