questions about "remote web services"

Sebastian Kügler sebas at kde.org
Wed May 18 16:14:22 CEST 2011


Hi Jérôme,

On Wednesday, May 18, 2011 15:36:38 Jérôme Pigeot wrote:
> I would like to write a youtube player plasmoid (simple search form and
> video view), like does minitube (http://flavio.tordini.org/minitube)
> The plan is to write the applet in QML/JS

That sounds like a good choice. :)

> What is more problematic for me is writing the dataengine : i've some lack
> to understand how it really works.

Maybe it isn't necessary to write your own dataengine, as there already is a 
dataengine for webvideo. It is in plasma-mediacenter (git clone kde:plasma-
mediacenter) and it's written in C++ itself. This dataengine loads plugins for 
video service providers (youtube, blip for example), the add-ons are written 
in JavaScript. Ideally this does what you need from the dataengine side of 
things.

> Imagine the plasmoid making a request with the word "soccer":
>   - it must query the dataengine with the keyword
>   - the dataengine must query the youtube api for that request with that url
> 
> : http://gdata.youtube.com/feeds/api/videos?vq=soccer
> 
>   - the dataengine will deserialize the XML/ATOM stream to convert it into
> keys/valors
>   - the source will be now available via a connection in the applet
> 
> Some questions about that:
> 
> If the search get a certain number of videos, how do you integrate it in the
> dataengine??? and then in the applet??
> The dataengine will just give infos to the applet : url of the video,
> image... that means the applet needs a to get the data via KIO??

It probably makes sense if the dataengine does the fetching, I haven't looked 
closely at the video egine, so I don't know off-hand how it's handled there, 
but it's probably a good starting point, and of course improvements can always 
be done later, if things don't work as you expect.

It's possible to put the retrieved image into the data set, so the QML 
Plasmoid can use it from there, and doesn't have to do its own fetching. That 
also makes it possible to share the previews across multiple applets. I've 
recently written a preview engine (which doesn't support youtube, but could be 
made to support it), that's an engine which is only for previews. You 
typically use it as additional dataengine in your QML "preview item". It 
caches the previews on disk through KImageCache, so it's quite fast and shares 
the cache even across processes.

> and more generally:
> 
> What is the "recommanded" language to write dataengines??

If possible, JavaScript since that makes it easy to deploy. You'll sometimes 
find yourself needing specific API that is only available from C++, so C++ 
dataengines are also an acceptable option. There's also the possibility to use 
Python, Ruby and other languages, but these have less coverage.

> Is it better to separate the dataengine and the applet sources or place them
> in the same "package"???

If it's a general purpose engine, it's usually best to provide it separetely, 
so it can be sensibly deployed to also allow other applets to use it.

Feel free to ask any further questions you might have, either here or on 
irc.freenode.net, #plasma.

Hope to help,
-- 
sebas

http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9


More information about the Plasma-devel mailing list