[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    About KDE scripting architecture.
From:       Koos Vriezen <koos.vriezen () xs4all ! nl>
Date:       2002-07-11 21:12:02
[Download RAW message or body]

Hi Zack,

I've read some of the postings today about calling function of a KDE app
from a script.

I've build the LiveConnectExtension for KParts for khtml (see
kdelibs/kparts/browserextension.h).
I also couldn't find a way to use DCOP for event (signal) handling,
without knowing it's exact signature in advance. Not to mention the
security problems exposing DCOP to a javascript in from a web page.

Here a summary of my approach:

There are now two applications using LiveConnect, kmultimedia/kaboodle and
kdelibs/khtml/java.

The LiveConnectExtension is based on how kjs works, 'put' and 'get' for
property settings and 'get' followed by 'call' for function calls.
Array's are properties in javascript (eg. myarry[5] = 0 becomes
put("5", "0", objref_of_myarray) where objref_of_myarray is from a 'get'
first).

The advantage of this approach is that khtml doesn't need to know or parse
a kparts interface, only the kpart itself and the programmer of the script
has to know.
It's also powerful enough to do about anything in the Java VM, allowed by
the Java's Security Manager of course.
The only thing missing, is iterating an object's method/properties from a
script (could be added though).
If the kpart knows the scripting engine, it can use the event mechanism,
for evaluating scripts in it's host. See
kdelibs/khtml/java/org/kde/javascript/JSObject.java as an example of this.
The Java to Javascript calls are a Javascript application injected in the
HTML page.
It's also simple enough for adding a stop/start/setLooping interface for a
mediaplayer in a few lines of code (see kdemultimedia/kaboodle/player.* as
an example). You can try
  <HTML><BODY>
  <EMBED src="file:/usr/local/kde3/share/sounds/KDE_Startup.wav"
   name="audio" width=250 height=100 type="audio/x-wav">
  </EMBED>
  <br>
  <A HREF="javascript:audio.play()">play</A>
  <A HREF="javascript:audio.stop()">stop</A>
  </BODY></HTML>
in khtml for this.

Hope this gives you some ideas.

Regards,

Koos Vriezen


 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic