fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / khtml / java / kjavaappletviewer.cpp
blobe03a99a6b5f5a349fc0482e984dfd6c6297ebf58
1 /* This file is part of the KDE project
3 * Copyright (C) 2003 Koos Vriezen <koos.vriezen@xs4all.nl>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #include "kjavaappletviewer.h"
23 #include "kjavaappletwidget.h"
24 #include "kjavaappletserver.h"
26 #include <stdio.h>
28 #ifdef KDE_USE_FINAL
29 #undef Always
30 #endif
31 #include <QtCore/QDir>
32 #include <QtCore/QPair>
33 #include <QtCore/QTimer>
34 #include <QtCore/QPointer>
35 #include <QtGui/QLabel>
36 #include <QtGui/QTableWidget>
37 #include <QtDBus/QtDBus>
39 #include <kauthorized.h>
40 #include <klibloader.h>
41 #include <kaboutdata.h>
42 #include <klocale.h>
43 #include <kstatusbar.h>
44 #include <kiconloader.h>
45 #include <kdebug.h>
46 #include <kconfig.h>
47 #include <kio/authinfo.h>
50 K_EXPORT_COMPONENT_FACTORY (kjavaappletviewer, KJavaAppletViewerFactory)
52 KComponentData *KJavaAppletViewerFactory::s_componentData = 0;
53 KIconLoader *KJavaAppletViewerFactory::s_iconLoader = 0;
55 KJavaAppletViewerFactory::KJavaAppletViewerFactory () {
56 s_componentData = new KComponentData("kjava");
57 s_iconLoader = new KIconLoader(s_componentData->componentName(), s_componentData->dirs());
60 KJavaAppletViewerFactory::~KJavaAppletViewerFactory () {
61 delete s_iconLoader;
62 delete s_componentData;
65 KParts::Part *KJavaAppletViewerFactory::createPartObject
66 (QWidget *wparent,
67 QObject *parent, const char *, const QStringList & args) {
68 return new KJavaAppletViewer (wparent, parent, args);
71 //-----------------------------------------------------------------------------
73 class KJavaServerMaintainer;
75 class KJavaServerMaintainer {
76 public:
77 KJavaServerMaintainer () { }
78 ~KJavaServerMaintainer ();
80 KJavaAppletContext * getContext (QObject*, const QString &);
81 void releaseContext (QObject*, const QString &);
82 void setServer (KJavaAppletServer * s);
83 QPointer <KJavaAppletServer> server;
84 private:
85 typedef QMap <QPair <QObject*, QString>, QPair <KJavaAppletContext*, int> >
86 ContextMap;
87 ContextMap m_contextmap;
89 K_GLOBAL_STATIC(KJavaServerMaintainer, serverMaintainer)
91 KJavaServerMaintainer::~KJavaServerMaintainer () {
92 delete server;
95 KJavaAppletContext * KJavaServerMaintainer::getContext (QObject * w, const QString & doc) {
96 QPair<QObject*,QString> key = qMakePair (w, doc);
97 ContextMap::iterator it = m_contextmap.find (key);
98 if (it != m_contextmap.end ()) {
99 ++((*it).second);
100 return (*it).first;
102 KJavaAppletContext* const context = new KJavaAppletContext ();
103 m_contextmap.insert (key, qMakePair(context, 1));
104 return context;
107 void KJavaServerMaintainer::releaseContext (QObject * w, const QString & doc) {
108 ContextMap::iterator it = m_contextmap.find (qMakePair (w, doc));
109 if (it != m_contextmap.end () && --(*it).second <= 0) {
110 kDebug(6100) << "KJavaServerMaintainer::releaseContext";
111 (*it).first->deleteLater ();
112 m_contextmap.erase (it);
116 inline void KJavaServerMaintainer::setServer (KJavaAppletServer * s) {
117 if (!server)
118 server = s;
121 //-----------------------------------------------------------------------------
123 AppletParameterDialog::AppletParameterDialog (KJavaAppletWidget * parent)
124 : KDialog(parent), m_appletWidget (parent)
126 setObjectName( "paramdialog" );
127 setCaption( i18n ("Applet Parameters") );
128 setButtons( KDialog::Close );
129 setDefaultButton( KDialog::Close );
130 showButtonSeparator( true );
131 setModal( true );
133 KJavaApplet* const applet = parent->applet ();
134 table = new QTableWidget (30, 2, this);
135 table->setMinimumSize (QSize (600, 400));
136 table->setColumnWidth (0, 200);
137 table->setColumnWidth (1, 340);
138 QTableWidgetItem* const header1 = new QTableWidgetItem(i18n ("Parameter"));
139 QTableWidgetItem* const header2 = new QTableWidgetItem(i18n ("Value"));
140 table->setHorizontalHeaderItem(1, header1);
141 table->setHorizontalHeaderItem(2, header2);
142 QTableWidgetItem * tit = new QTableWidgetItem(i18n("Class"));
143 tit->setFlags( tit->flags()^Qt::ItemIsEditable );
144 table->setItem (0, 0, tit);
145 tit = new QTableWidgetItem(applet->appletClass());
146 tit->setFlags( tit->flags()|Qt::ItemIsEditable );
147 table->setItem (0, 1, tit);
148 tit = new QTableWidgetItem (i18n ("Base URL"));
149 tit->setFlags( tit->flags()^Qt::ItemIsEditable );
150 table->setItem (1, 0, tit);
151 tit = new QTableWidgetItem(applet->baseURL());
152 tit->setFlags( tit->flags()|Qt::ItemIsEditable );
153 table->setItem (1, 1, tit);
154 tit = new QTableWidgetItem(i18n ("Archives"));
155 tit->setFlags( tit->flags()^Qt::ItemIsEditable );
156 table->setItem (2, 0, tit);
157 tit = new QTableWidgetItem(applet->archives());
158 tit->setFlags( tit->flags()|Qt::ItemIsEditable );
159 table->setItem (2, 1, tit);
160 QMap<QString,QString>::const_iterator it = applet->getParams().constBegin();
161 const QMap<QString,QString>::const_iterator itEnd = applet->getParams().constEnd();
162 for (int count = 2; it != itEnd; ++it) {
163 tit = new QTableWidgetItem (it.key ());
164 tit->setFlags( tit->flags()|Qt::ItemIsEditable );
165 table->setItem (++count, 0, tit);
166 tit = new QTableWidgetItem(it.value());
167 tit->setFlags( tit->flags()|Qt::ItemIsEditable );
168 table->setItem (count, 1, tit);
170 setMainWidget (table);
171 connect(this,SIGNAL(closeClicked()),this,SLOT(slotClose()));
174 void AppletParameterDialog::slotClose () {
175 table->setRangeSelected(QTableWidgetSelectionRange(0, 0, 0, 0), true);
176 KJavaApplet* const applet = m_appletWidget->applet ();
177 applet->setAppletClass (table->item (0, 1)->text ());
178 applet->setBaseURL (table->item (1, 1)->text ());
179 applet->setArchives (table->item (2, 1)->text ());
180 const int lim = table->rowCount();
181 for (int i = 3; i < lim; ++i) {
182 if (table->item (i, 0) && table->item (i, 1) && !table->item (i, 0)->text ().isEmpty ())
183 applet->setParameter (table->item (i, 0)->text (),
184 table->item (i, 1)->text ());
186 hide ();
188 //-----------------------------------------------------------------------------
190 class CoverWidget : public QWidget {
191 KJavaAppletWidget * m_appletwidget;
192 public:
193 CoverWidget (QWidget *);
194 ~CoverWidget () {}
195 KJavaAppletWidget * appletWidget () const;
196 protected:
197 void resizeEvent (QResizeEvent * e);
200 inline CoverWidget::CoverWidget (QWidget * parent)
201 : QWidget (parent )
203 setObjectName( "KJavaAppletViewer Widget");
204 m_appletwidget = new KJavaAppletWidget (this);
205 setFocusProxy (m_appletwidget);
208 inline KJavaAppletWidget * CoverWidget::appletWidget () const {
209 return m_appletwidget;
212 void CoverWidget::resizeEvent (QResizeEvent * e) {
213 m_appletwidget->resize (e->size().width(), e->size().height());
216 //-----------------------------------------------------------------------------
218 class StatusBarIcon : public QLabel {
219 public:
220 StatusBarIcon (QWidget * parent) : QLabel (parent) {
221 setPixmap ( KJavaAppletViewerFactory::iconLoader()->loadIcon("java", KIconLoader::Small) );
223 protected:
224 void mousePressEvent (QMouseEvent *) {
225 serverMaintainer->server->showConsole ();
229 //-----------------------------------------------------------------------------
231 KJavaAppletViewer::KJavaAppletViewer (QWidget * wparent,
232 QObject * parent, const QStringList & args)
233 : KParts::ReadOnlyPart (parent),
234 m_browserextension (new KJavaAppletViewerBrowserExtension (this)),
235 m_liveconnect (new KJavaAppletViewerLiveConnectExtension (this)),
236 m_statusbar (new KParts::StatusBarExtension (this)),
237 m_statusbar_icon (0L),
238 m_closed (true)
240 m_view = new CoverWidget (wparent);
241 QString classname, classid, codebase, khtml_codebase, src_param;
242 QString appletname;
243 int width = -1;
244 int height = -1;
245 KJavaApplet* const applet = m_view->appletWidget()->applet ();
246 QStringList::const_iterator it = args.begin();
247 const QStringList::const_iterator itEnd = args.end();
248 for ( ; it != itEnd; ++it) {
249 const int equalPos = (*it).indexOf("=");
250 if (equalPos > 0) {
251 const QString name = (*it).left (equalPos).toUpper ();
252 QString value = (*it).right ((*it).length () - equalPos - 1);
253 if (value.at(0)=='\"')
254 value = value.right (value.length () - 1);
255 if (value.at (value.length () - 1) == '\"')
256 value.truncate (value.length () - 1);
257 kDebug(6100) << "name=" << name << " value=" << value;
258 if (!name.isEmpty()) {
259 const QString name_lower = name.toLower ();
260 if (name == "__KHTML__PLUGINBASEURL") {
261 baseurl = KUrl (KUrl (value), QString (".")).url ();
262 } else if (name == "__KHTML__CODEBASE")
263 khtml_codebase = value;
264 else if (name_lower == QLatin1String("codebase") ||
265 name_lower == QLatin1String("java_codebase")) {
266 if (!value.isEmpty ())
267 codebase = value;
268 } else if (name == "__KHTML__CLASSID")
269 //else if (name.toLower()==QLatin1String("classid"))
270 classid = value;
271 else if (name_lower == QLatin1String("code") ||
272 name_lower == QLatin1String("java_code"))
273 classname = value;
274 else if (name_lower == QLatin1String("src"))
275 src_param = value;
276 else if (name_lower == QLatin1String("archive") ||
277 name_lower == QLatin1String("java_archive") ||
278 name_lower.startsWith(QLatin1String("cache_archive")))
279 applet->setArchives (value);
280 else if (name_lower == QLatin1String("name"))
281 appletname = value;
282 else if (name_lower == QLatin1String("width"))
283 width = value.toInt();
284 else if (name_lower == QLatin1String("height"))
285 height = value.toInt();
286 if (!name.startsWith(QLatin1String("__KHTML__"))) {
287 applet->setParameter (name, value);
292 if (!classid.isEmpty ()) {
293 applet->setParameter ("CLSID", classid);
294 kDebug(6100) << "classid=" << classid << classid.startsWith("clsid:");
295 if (classid.startsWith(QLatin1String("clsid:")))
296 // codeBase contains the URL to the plugin page
297 khtml_codebase = baseurl;
298 else if (classname.isEmpty () && classid.startsWith(QLatin1String("java:")))
299 classname = classid.mid(5);
301 if (classname.isEmpty ())
302 classname = src_param;
303 else if (!src_param.isEmpty ())
304 applet->setParameter (QString ("SRC"), src_param);
305 if (codebase.isEmpty ())
306 codebase = khtml_codebase;
307 if (baseurl.isEmpty ()) {
308 // not embedded in khtml
309 QString pwd = QDir().absolutePath ();
310 if (!pwd.endsWith ( QString(QDir::separator ())))
311 pwd += QDir::separator ();
312 baseurl = KUrl (KUrl (pwd), codebase).url ();
314 if (width > 0 && height > 0) {
315 m_view->resize (width, height);
316 applet->setSize( QSize( width, height ) );
318 if (appletname.isEmpty())
319 appletname = classname;
320 applet->setAppletName (appletname);
321 applet->setBaseURL (baseurl);
322 // check codebase first
323 const KUrl kbaseURL( baseurl );
324 const KUrl newURL(kbaseURL, codebase);
325 if (KAuthorized::authorizeUrlAction("redirect", KUrl(baseurl), newURL))
326 applet->setCodeBase (newURL.url());
327 applet->setAppletClass (classname);
328 KJavaAppletContext* const cxt = serverMaintainer->getContext (parent, baseurl);
329 applet->setAppletContext (cxt);
331 KJavaAppletServer* const server = cxt->getServer ();
333 serverMaintainer->setServer (server);
335 if (!server->usingKIO ()) {
336 /* if this page needs authentication */
337 KIO::AuthInfo info;
338 info.url = baseurl;
339 info.verifyPath = true;
340 QByteArray params;
341 { QDataStream stream(&params, QIODevice::WriteOnly); stream << info; }
343 // make the call
344 QDBusReply<QByteArray> reply =
345 QDBusInterface("org.kde.kded", "/modules/kpasswdserver", "org.kde.KPasswdServer").
346 call ("checkAuthInfo", params, qlonglong(m_view->topLevelWidget()->winId()));
348 if (!reply.isValid()) {
349 kWarning() << "Can't communicate with kded_kpasswdserver!";
350 } else {
351 KIO::AuthInfo authResult;
352 QDataStream stream2(reply.value());
353 stream2 >> authResult;
354 applet->setUser (authResult.username);
355 applet->setPassword (authResult.password);
356 applet->setAuthName (authResult.realmValue);
360 /* install event filter for close events */
361 if (wparent)
362 wparent->topLevelWidget ()->installEventFilter (this);
364 setComponentData (KJavaAppletViewerFactory::componentData());
365 KParts::Part::setWidget (m_view);
367 connect (applet->getContext(), SIGNAL(appletLoaded()), this, SLOT(appletLoaded()));
368 connect (applet->getContext(), SIGNAL(showDocument(const QString&, const QString&)), m_browserextension, SLOT(showDocument(const QString&, const QString&)));
369 connect (applet->getContext(), SIGNAL(showStatus(const QString &)), this, SLOT(infoMessage(const QString &)));
370 connect (applet, SIGNAL(jsEvent (const QStringList &)), m_liveconnect, SLOT(jsEvent (const QStringList &)));
373 CoverWidget * KJavaAppletViewer::view () const
375 return m_view;
379 bool KJavaAppletViewer::eventFilter (QObject *o, QEvent *e) {
380 if (m_liveconnect->jsSessions () > 0) {
381 switch (e->type()) {
382 case QEvent::Destroy:
383 case QEvent::Close:
384 case QEvent::Quit:
385 return true;
386 default:
387 break;
390 return KParts::ReadOnlyPart::eventFilter(o,e);
393 KJavaAppletViewer::~KJavaAppletViewer () {
394 m_view = 0L;
395 serverMaintainer->releaseContext (parent(), baseurl);
396 if (m_statusbar_icon) {
397 m_statusbar->removeStatusBarItem (m_statusbar_icon);
398 delete m_statusbar_icon;
402 bool KJavaAppletViewer::openUrl (const KUrl & url) {
403 if (!m_view) return false;
404 m_closed = false;
405 KJavaAppletWidget* const w = m_view->appletWidget ();
406 KJavaApplet* const applet = w->applet ();
407 if (applet->isCreated ())
408 applet->stop ();
409 if (applet->appletClass ().isEmpty ()) {
410 // preview without setting a class?
411 if (applet->baseURL ().isEmpty ()) {
412 applet->setAppletClass (url.fileName ());
413 applet->setBaseURL (url.upUrl ().url ());
414 } else
415 applet->setAppletClass (url.url ());
416 AppletParameterDialog (w).exec ();
417 applet->setSize (w->sizeHint());
419 if (!m_statusbar_icon) {
420 KStatusBar *sb = m_statusbar->statusBar();
421 if (sb) {
422 m_statusbar_icon = new StatusBarIcon (sb);
423 m_statusbar->addStatusBarItem (m_statusbar_icon, 0, false);
426 // delay showApplet if size is unknown and m_view not shown
427 if (applet->size().width() > 0 || m_view->isVisible())
428 w->showApplet ();
429 else
430 QTimer::singleShot (10, this, SLOT (delayedCreateTimeOut ()));
431 if (!applet->failed ())
432 emit started (0L);
433 return url.isValid ();
436 bool KJavaAppletViewer::closeUrl () {
437 kDebug(6100) << "closeUrl";
438 m_closed = true;
439 KJavaApplet* const applet = m_view->appletWidget ()->applet ();
440 if (applet->isCreated ())
441 applet->stop ();
442 applet->getContext()->getServer()->endWaitForReturnData();
443 return true;
446 bool KJavaAppletViewer::appletAlive () const {
447 return !m_closed && m_view &&
448 m_view->appletWidget ()->applet () &&
449 m_view->appletWidget ()->applet ()->isAlive ();
452 bool KJavaAppletViewer::openFile () {
453 return false;
456 void KJavaAppletViewer::delayedCreateTimeOut () {
457 KJavaAppletWidget* const w = m_view->appletWidget ();
458 if (!w->applet ()->isCreated () && !m_closed)
459 w->showApplet ();
462 void KJavaAppletViewer::appletLoaded () {
463 if (!m_view) return;
464 KJavaApplet* const applet = m_view->appletWidget ()->applet ();
465 if (applet->isAlive() || applet->failed())
466 emit completed();
469 void KJavaAppletViewer::infoMessage (const QString & msg) {
470 m_browserextension->infoMessage(msg);
473 KAboutData* KJavaAppletViewer::createAboutData () {
474 return new KAboutData("KJavaAppletViewer", 0, ki18n("KDE Java Applet Plugin"), "1.0");
477 //---------------------------------------------------------------------
479 KJavaAppletViewerBrowserExtension::KJavaAppletViewerBrowserExtension (KJavaAppletViewer * parent)
480 : KParts::BrowserExtension (parent )
482 setObjectName( "KJavaAppletViewer Browser Extension" );
485 void KJavaAppletViewerBrowserExtension::urlChanged (const QString & url) {
486 emit setLocationBarUrl (url);
489 void KJavaAppletViewerBrowserExtension::setLoadingProgress (int percentage) {
490 emit loadingProgress (percentage);
493 void KJavaAppletViewerBrowserExtension::setBrowserArguments (const KParts::BrowserArguments & /*args*/) {
496 void KJavaAppletViewerBrowserExtension::saveState (QDataStream & stream) {
497 KJavaApplet* const applet = static_cast<KJavaAppletViewer*>(parent())->view()->appletWidget ()->applet ();
498 stream << applet->appletClass();
499 stream << applet->baseURL();
500 stream << applet->archives();
501 stream << applet->getParams().size ();
502 QMap<QString,QString>::const_iterator it = applet->getParams().constBegin();
503 const QMap<QString,QString>::const_iterator itEnd = applet->getParams().constEnd();
504 for ( ; it != itEnd; ++it) {
505 stream << it.key ();
506 stream << it.value ();
510 void KJavaAppletViewerBrowserExtension::restoreState (QDataStream & stream) {
511 KJavaAppletWidget* const w = static_cast<KJavaAppletViewer*>(parent())->view()->appletWidget();
512 KJavaApplet* const applet = w->applet ();
513 QString key, val;
514 int paramcount;
515 stream >> val;
516 applet->setAppletClass (val);
517 stream >> val;
518 applet->setBaseURL (val);
519 stream >> val;
520 applet->setArchives (val);
521 stream >> paramcount;
522 for (int i = 0; i < paramcount; ++i) {
523 stream >> key;
524 stream >> val;
525 applet->setParameter (key, val);
526 kDebug(6100) << "restoreState key:" << key << " val:" << val;
528 applet->setSize (w->sizeHint ());
529 if (w->isVisible())
530 w->showApplet ();
533 void KJavaAppletViewerBrowserExtension::showDocument (const QString & doc,
534 const QString & frame) {
535 const KUrl url (doc);
536 KParts::BrowserArguments browserArgs;
537 browserArgs.frameName = frame;
538 emit openUrlRequest(url, KParts::OpenUrlArguments(), browserArgs);
541 //-----------------------------------------------------------------------------
543 KJavaAppletViewerLiveConnectExtension::KJavaAppletViewerLiveConnectExtension(KJavaAppletViewer * parent)
544 : KParts::LiveConnectExtension (parent ), m_viewer (parent)
546 setObjectName( "KJavaAppletViewer LiveConnect Extension" );
549 bool KJavaAppletViewerLiveConnectExtension::get (
550 const unsigned long objid, const QString & name,
551 KParts::LiveConnectExtension::Type & type,
552 unsigned long & rid, QString & value)
554 if (!m_viewer->appletAlive ())
555 return false;
556 QStringList args, ret_args;
557 KJavaApplet* const applet = m_viewer->view ()->appletWidget ()->applet ();
558 args.append (QString::number (applet->appletId ()));
559 args.append (QString::number ((int) objid));
560 args.append (name);
561 m_jssessions++;
562 const bool ret = applet->getContext()->getMember (args, ret_args);
563 m_jssessions--;
564 if (!ret || ret_args.count() != 3) return false;
565 bool ok;
566 int itype = ret_args[0].toInt (&ok);
567 if (!ok || itype < 0) return false;
568 type = (KParts::LiveConnectExtension::Type) itype;
569 rid = ret_args[1].toInt (&ok);
570 if (!ok) return false;
571 value = ret_args[2];
572 return true;
575 bool KJavaAppletViewerLiveConnectExtension::put(const unsigned long objid, const QString & name, const QString & value)
577 if (!m_viewer->appletAlive ())
578 return false;
579 QStringList args;
580 KJavaApplet* const applet = m_viewer->view ()->appletWidget ()->applet ();
581 args.append (QString::number (applet->appletId ()));
582 args.append (QString::number ((int) objid));
583 args.append (name);
584 args.append (value);
585 ++m_jssessions;
586 const bool ret = applet->getContext()->putMember (args);
587 --m_jssessions;
588 return ret;
591 bool KJavaAppletViewerLiveConnectExtension::call( const unsigned long objid, const QString & func, const QStringList & fargs, KParts::LiveConnectExtension::Type & type, unsigned long & retobjid, QString & value )
593 if (!m_viewer->appletAlive ())
594 return false;
595 KJavaApplet* const applet = m_viewer->view ()->appletWidget ()->applet ();
596 QStringList args, ret_args;
597 args.append (QString::number (applet->appletId ()));
598 args.append (QString::number ((int) objid));
599 args.append (func);
601 QStringList::const_iterator it = fargs.begin();
602 const QStringList::const_iterator itEnd = fargs.end();
603 for ( ; it != itEnd; ++it)
604 args.append(*it);
607 ++m_jssessions;
608 const bool ret = applet->getContext()->callMember (args, ret_args);
609 --m_jssessions;
610 if (!ret || ret_args.count () != 3) return false;
611 bool ok;
612 const int itype = ret_args[0].toInt (&ok);
613 if (!ok || itype < 0) return false;
614 type = (KParts::LiveConnectExtension::Type) itype;
615 retobjid = ret_args[1].toInt (&ok);
616 if (!ok) return false;
617 value = ret_args[2];
618 return true;
621 void KJavaAppletViewerLiveConnectExtension::unregister(const unsigned long objid)
623 if (!m_viewer->view () || !m_viewer->view ())
624 return;
625 KJavaApplet* const applet = m_viewer->view ()->appletWidget ()->applet ();
626 if (!applet || objid == 0) {
627 // typically a gc after a function call on the applet,
628 // no need to send to the jvm
629 return;
631 QStringList args;
632 args.append (QString::number (applet->appletId ()));
633 args.append (QString::number ((int) objid));
634 applet->getContext()->derefObject (args);
637 void KJavaAppletViewerLiveConnectExtension::jsEvent (const QStringList & args) {
638 if (args.count () < 2 || !m_viewer->appletAlive ())
639 return;
640 bool ok;
641 QStringList::ConstIterator it = args.begin();
642 const QStringList::ConstIterator itEnd = args.end();
643 const unsigned long objid = (*it).toInt(&ok);
644 ++it;
645 const QString event = (*it);
646 ++it;
647 KParts::LiveConnectExtension::ArgList arglist;
649 for (; it != itEnd; ++it) {
650 // take a deep breath here
651 const QStringList::ConstIterator prev = it++;
652 arglist.push_back(KParts::LiveConnectExtension::ArgList::value_type((KParts::LiveConnectExtension::Type) (*prev).toInt(), (*it)));
654 emit partEvent (objid, event, arglist);
657 int KJavaAppletViewerLiveConnectExtension::m_jssessions = 0;
659 //-----------------------------------------------------------------------------
661 #include "kjavaappletviewer.moc"