This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Using IOJob within development of a plasmoid in java script

Tags: None
(comma "," separated)
sunny
Registered Member
Posts
2
Karma
0
Hello :)

I've just started developing a plasmoid in java script and have some questions.

My goal is to load xml-data from a remote url, parse it, and print out the results in my plasmoid.

Until yet I've only managed to access the remote url via this:

Code: Select all
var url = Url("http://myremoteURL-that-generates-xml");
var getJob = plasmoid.getUrl(url);


My first question: How can I access the returned data? I don't understand the information concerning IOJob in the API. I cant really be writing:

Code: Select all
var myByteArray = new ByteArray();
getJob.data(getJob, myByteArray);


?!

Oh and concening the parsing, I read that ECMA-Scripts doesn't support DOM-Functionality so I have to switch to using something like xml_for_scripts. Am I mistaken?

I hope someone could help me with these 2 questions :)

Sunny
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Please see http://techbase.kde.org/Development/Tut ... /API#IOJob

You should connect to the data(IOJob job, ByteArray data) and finished(IOJob job) Signals, and perform the XML parsing in appropriate connected slots.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
sunny
Registered Member
Posts
2
Karma
0
well, this doesn't help much. As I already said, I don't understand the information in the api concerning IOjob...

It would be nice if u could give an example. - I know that I have to use the data function and finished function - but I'd like to see how! On which object do i call the data / finished function..

And what "appropriate connected slots" are u talking about?

Please be more precise!!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The IOJob API is a wrapper around the KDE KJob API, which is async. This means that the plasmoid.getUrl() call you make will return immediately, rather than after the request is completed.

To allow you to access the returned data, the getUrl() call returns an instance of IOJob, which will emit several signals when certain stages of the operation have been reached.

I would recommend reading http://doc.trolltech.com/4.6/signalsandslots.html for further information on how signals and slots ( your local functions for handling the data ) work.

In essence, you need to connect the signals of the IOJob to the "slots" ( or functions ) of your plasmoid.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]