KHtml

kjavaapplet.h
1 // -*- c++ -*-
2 /* This file is part of the KDE project
3  *
4  * Copyright (C) 2000 Richard Moore <[email protected]>
5  * 2000 Wynn Wilkes <[email protected]>
6  *
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.
11  *
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.
16  *
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.
21  */
22 
23 #ifndef KJAVAAPPLET_H
24 #define KJAVAAPPLET_H
25 
26 #include <QObject>
27 #include <QStringList>
28 #include <QMap>
29 
30 /**
31  * @short A Java applet
32  *
33  * This class encapsulates the data the Applet Server needs to load
34  * the Applet class files, and set the proper size of the Applet. It also
35  * has an interface for applets to resize themselves.
36  *
37  * @author Richard J. Moore, [email protected]
38  * @author Wynn Wilkes, [email protected]
39  */
40 
41 class KJavaApplet;
42 class KJavaAppletWidget;
43 class KJavaAppletContext;
44 class KJavaAppletPrivate;
45 
46 class KJavaApplet : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51  // states describing the life cycle of an applet.
52  // keep in sync with applet state in KJASAppletStub.java !
53  typedef enum {
54  UNKNOWN = 0,
55  CLASS_LOADED = 1,
56  INSTANCIATED = 2,
57  INITIALIZED = 3,
58  STARTED = 4,
59  STOPPED = 5,
60  DESTROYED = 6
61  } AppletState;
62  KJavaApplet(KJavaAppletWidget *_parent, KJavaAppletContext *_context = nullptr);
63  ~KJavaApplet();
64 
65  /**
66  * Set the applet context'.
67  */
68  void setAppletContext(KJavaAppletContext *_context);
69 
70  /**
71  * Specify the name of the class file to run. For example 'Lake.class'.
72  */
73  void setAppletClass(const QString &clazzName);
74 
75  /**
76  * Get the name of the Class file the applet should run
77  */
78  QString &appletClass();
79 
80  /**
81  * Set the URL of the document embedding the applet.
82  */
83  void setBaseURL(const QString &base);
84 
85  /**
86  * get the Base URL of the document embedding the applet
87  */
88  QString &baseURL();
89 
90  /**
91  * Set the codebase of the applet classes.
92  */
93  void setCodeBase(const QString &codeBase);
94 
95  /**
96  * Get the codebase of the applet classes
97  */
98  QString &codeBase();
99 
100  /**
101  * Set the list of archives at the Applet's codebase to search in for
102  * class files and other resources
103  */
104  void setArchives(const QString &_archives);
105 
106  /**
107  * Get the list of Archives that should be searched for class files
108  * and other resources
109  */
110  QString &archives();
111 
112  /**
113  * Set the name the applet should be called in its context
114  */
115  void setAppletName(const QString &name);
116 
117  /**
118  * Get the name the applet should be called in its context
119  */
120  QString &appletName();
121 
122  /**
123  * Set the size of the applet
124  */
125  void setSize(QSize size);
126 
127  /**
128  * Get the size of the applet
129  */
130  QSize size();
131 
132  /**
133  * Specify a parameter to be passed to the applet.
134  */
135  void setParameter(const QString &name, const QString &value);
136 
137  /**
138  * Look up the parameter value for the given Parameter. Returns
139  * QString() if the name has not been set.
140  */
141  QString &parameter(const QString &name);
142 
143  /**
144  * Get a reference to the Parameters and their values
145  */
146  QMap<QString, QString> &getParams();
147 
148  /**
149  * Set the window title for swallowing
150  */
151  void setWindowName(const QString &title);
152 
153  /**
154  * Get the window title this applet should use
155  */
156  QString &getWindowName();
157 
158  /**
159  * Interface for applets to resize themselves
160  */
161  void resizeAppletWidget(int width, int height);
162 
163  /**
164  * Send message to AppletServer to create this applet's
165  * frame to be swallowed and download the applet classes
166  */
167  void create();
168 
169  /**
170  * Send message to AppletServer to Initialize and show
171  * this applet
172  */
173  void init();
174 
175  /**
176  * Returns status of applet- whether it's been created or not
177  */
178  bool isCreated();
179 
180  /**
181  * Run the applet.
182  */
183  void start();
184 
185  /**
186  * Pause the applet.
187  */
188  void stop();
189 
190  /**
191  * Returns the unique ID this applet is given
192  */
193  int appletId();
194 
195  /**
196  * Set the applet ID.
197  */
198  void setAppletId(int id);
199 
200  KJavaAppletContext *getContext() const
201  {
202  return context;
203  }
204 
205  /**
206  * Get/Set the user name
207  */
208  void setUser(const QString &_user)
209  {
210  username = _user;
211  }
212  const QString &user() const
213  {
214  return username;
215  }
216 
217  /**
218  * Get/Set the user password
219  */
220  void setPassword(const QString &_password)
221  {
222  userpassword = _password;
223  }
224  const QString &password() const
225  {
226  return userpassword;
227  }
228 
229  /**
230  * Get/Set the auth name
231  */
232  void setAuthName(const QString &_auth)
233  {
234  authname = _auth;
235  }
236  const QString &authName() const
237  {
238  return authname;
239  }
240 
241  /**
242  * called from the protocol engine
243  * changes the status according to the one on the java side.
244  * Do not call this yourself!
245  */
246  void stateChange(const int newState);
247  void setFailed();
248  AppletState state() const;
249  bool failed() const;
250  bool isAlive() const;
251  /**
252  * JavaScript coming from Java
253  **/
254  void jsData(const QStringList &args)
255  {
256  emit jsEvent(args);
257  }
258 Q_SIGNALS:
259  void jsEvent(const QStringList &args);
260 private:
261  void showStatus(const QString &msg);
262  KJavaAppletPrivate *const d;
263  QMap<QString, QString> params;
264  KJavaAppletContext *context;
265  int id;
266  QString username;
267  QString userpassword;
268  QString authname;
269 };
270 
271 #endif // KJAVAAPPLET_H
QAction * create(StandardAction id, const QObject *recvr, Func slot, QObject *parent)
Q_SIGNALSQ_SIGNALS
KGuiItem stop()
Q_OBJECTQ_OBJECT
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:47:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.