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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
// -*- c++ -*-
/* 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 KJAVAAPPLET_H
#define KJAVAAPPLET_H
#include <kurl.h>
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QMap>
/**
* @short A Java applet
*
* This class encapsulates the data the Applet Server needs to load
* the Applet class files, and set the proper size of the Applet. It also
* has an interface for applets to resize themselves.
*
* @author Richard J. Moore, rich@kde.org
* @author Wynn Wilkes, wynnw@kde.org
*/
class KJavaApplet;
class KJavaAppletWidget;
class KJavaAppletContext;
class KJavaAppletPrivate;
class KJavaApplet : public QObject
{
Q_OBJECT
public:
// states describing the life cycle of an applet.
// keep in sync with applet state in KJASAppletStub.java !
typedef enum {
UNKNOWN = 0,
CLASS_LOADED = 1,
INSTANCIATED = 2,
INITIALIZED = 3,
STARTED = 4,
STOPPED = 5,
DESTROYED = 6
} AppletState;
KJavaApplet( KJavaAppletWidget* _parent, KJavaAppletContext* _context = 0 );
~KJavaApplet();
/**
* Set the applet context'.
*/
void setAppletContext( KJavaAppletContext* _context );
/**
* Specify the name of the class file to run. For example 'Lake.class'.
*/
void setAppletClass( const QString& clazzName );
/**
* Get the name of the Class file the applet should run
*/
QString& appletClass();
/**
* Set the URL of the document embedding the applet.
*/
void setBaseURL( const QString& base );
/**
* get the Base URL of the document embedding the applet
*/
QString& baseURL();
/**
* Set the codebase of the applet classes.
*/
void setCodeBase( const QString& codeBase );
/**
* Get the codebase of the applet classes
*/
QString& codeBase();
/**
* Set the list of archives at the Applet's codebase to search in for
* class files and other resources
*/
void setArchives( const QString& _archives );
/**
* Get the list of Archives that should be searched for class files
* and other resources
*/
QString& archives();
/**
* Set the name the applet should be called in its context
*/
void setAppletName( const QString& name );
/**
* Get the name the applet should be called in its context
*/
QString& appletName();
/**
* Set the size of the applet
*/
void setSize( QSize size );
/**
* Get the size of the applet
*/
QSize size();
/**
* Specify a parameter to be passed to the applet.
*/
void setParameter( const QString& name, const QString& value );
/**
* Look up the parameter value for the given Parameter. Returns
* QString() if the name has not been set.
*/
QString& parameter( const QString& name );
/**
* Get a reference to the Parameters and their values
*/
QMap<QString,QString>& getParams();
/**
* Set the window title for swallowing
*/
void setWindowName( const QString& title );
/**
* Get the window title this applet should use
*/
QString& getWindowName();
/**
* Interface for applets to resize themselves
*/
void resizeAppletWidget( int width, int height );
/**
* Send message to AppletServer to create this applet's
* frame to be swallowed and download the applet classes
*/
void create();
/**
* Send message to AppletServer to Initialize and show
* this applet
*/
void init();
/**
* Returns status of applet- whether it's been created or not
*/
bool isCreated();
/**
* Run the applet.
*/
void start();
/**
* Pause the applet.
*/
void stop();
/**
* Returns the unique ID this applet is given
*/
int appletId();
/**
* Set the applet ID.
*/
void setAppletId( int id );
KJavaAppletContext* getContext() const { return context; }
/**
* Get/Set the user name
*/
void setUser(const QString & _user) { username = _user; }
const QString & user () const { return username; }
/**
* Get/Set the user password
*/
void setPassword(const QString & _password) { userpassword = _password; }
const QString & password () const { return userpassword; }
/**
* Get/Set the auth name
*/
void setAuthName(const QString & _auth) { authname = _auth; }
const QString & authName () const { return authname; }
/**
* called from the protocol engine
* changes the status according to the one on the java side.
* Do not call this yourself!
*/
void stateChange ( const int newState );
void setFailed ();
AppletState state() const;
bool failed() const;
bool isAlive() const;
/**
* JavaScript coming from Java
**/
void jsData (const QStringList & args) { emit jsEvent (args); }
Q_SIGNALS:
void jsEvent (const QStringList & args);
private:
void showStatus( const QString &msg);
KJavaAppletPrivate* const d;
QMap<QString, QString> params;
KJavaAppletContext* context;
int id;
QString username;
QString userpassword;
QString authname;
};
#endif // KJAVAAPPLET_H
|