2 /* This file is part of the KDE project
4 * Copyright (C) 2000 Richard Moore <rich@kde.org>
5 * 2000 Wynn Wilkes <wynnw@caldera.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
29 #include <QtCore/QObject>
30 #include <QtCore/QStringList>
31 #include <QtCore/QMap>
34 * @short A Java applet
36 * This class encapsulates the data the Applet Server needs to load
37 * the Applet class files, and set the proper size of the Applet. It also
38 * has an interface for applets to resize themselves.
40 * @author Richard J. Moore, rich@kde.org
41 * @author Wynn Wilkes, wynnw@kde.org
45 class KJavaAppletWidget
;
46 class KJavaAppletContext
;
47 class KJavaAppletPrivate
;
50 class KJavaApplet
: public QObject
55 // states describing the life cycle of an applet.
56 // keep in sync with applet state in KJASAppletStub.java !
66 KJavaApplet( KJavaAppletWidget
* _parent
, KJavaAppletContext
* _context
= 0 );
70 * Set the applet context'.
72 void setAppletContext( KJavaAppletContext
* _context
);
75 * Specify the name of the class file to run. For example 'Lake.class'.
77 void setAppletClass( const QString
& clazzName
);
80 * Get the name of the Class file the applet should run
82 QString
& appletClass();
85 * Set the URL of the document embedding the applet.
87 void setBaseURL( const QString
& base
);
90 * get the Base URL of the document embedding the applet
95 * Set the codebase of the applet classes.
97 void setCodeBase( const QString
& codeBase
);
100 * Get the codebase of the applet classes
105 * Set the list of archives at the Applet's codebase to search in for
106 * class files and other resources
108 void setArchives( const QString
& _archives
);
111 * Get the list of Archives that should be searched for class files
112 * and other resources
117 * Set the name the applet should be called in its context
119 void setAppletName( const QString
& name
);
122 * Get the name the applet should be called in its context
124 QString
& appletName();
127 * Set the size of the applet
129 void setSize( QSize size
);
132 * Get the size of the applet
137 * Specify a parameter to be passed to the applet.
139 void setParameter( const QString
& name
, const QString
& value
);
142 * Look up the parameter value for the given Parameter. Returns
143 * QString() if the name has not been set.
145 QString
& parameter( const QString
& name
);
148 * Get a reference to the Parameters and their values
150 QMap
<QString
,QString
>& getParams();
153 * Set the window title for swallowing
155 void setWindowName( const QString
& title
);
158 * Get the window title this applet should use
160 QString
& getWindowName();
163 * Interface for applets to resize themselves
165 void resizeAppletWidget( int width
, int height
);
168 * Send message to AppletServer to create this applet's
169 * frame to be swallowed and download the applet classes
174 * Send message to AppletServer to Initialize and show
180 * Returns status of applet- whether it's been created or not
195 * Returns the unique ID this applet is given
202 void setAppletId( int id
);
204 KJavaAppletContext
* getContext() const { return context
; }
207 * Get/Set the user name
209 void setUser(const QString
& _user
) { username
= _user
; }
210 const QString
& user () const { return username
; }
213 * Get/Set the user password
215 void setPassword(const QString
& _password
) { userpassword
= _password
; }
216 const QString
& password () const { return userpassword
; }
219 * Get/Set the auth name
221 void setAuthName(const QString
& _auth
) { authname
= _auth
; }
222 const QString
& authName () const { return authname
; }
225 * called from the protocol engine
226 * changes the status according to the one on the java side.
227 * Do not call this yourself!
229 void stateChange ( const int newState
);
231 AppletState
state() const;
233 bool isAlive() const;
235 * JavaScript coming from Java
237 void jsData (const QStringList
& args
) { emit
jsEvent (args
); }
239 void jsEvent (const QStringList
& args
);
241 void showStatus( const QString
&msg
);
242 KJavaAppletPrivate
* const d
;
243 QMap
<QString
, QString
> params
;
244 KJavaAppletContext
* context
;
247 QString userpassword
;
251 #endif // KJAVAAPPLET_H