(A)synchronous DataEngines?

Christopher Blauvelt cblauvelt at gmail.com
Sat Mar 8 00:50:14 CET 2008


On Fri, Mar 7, 2008 at 4:22 PM, Bernhard Beschow <bbeschow at cs.tu-berlin.de>
wrote:

> Hi all,
>
> inside a data engine I'd like to request some data via http. There is the
> QHttp class I could use as well as KIO. Both of them seem to be
> asynchronous.
> Now I ran into trouble combining those with DataEngines for the following
> reason:
>
> In my data engine, data is fetched asynchronously via QHttp each time
> updateSource gets called. After sending the request, the method returns
> false,
> while the QHttp object is waiting for a response. When new data is
> available,
> it is applied using setData, but the visualizations don't get updated
> until
> updateSource gets called next time. Even worse, this results in old data
> to
> be displayed. So I wonder what the proper way is to implement asynchronous
> data retrieval?
>
> Of course, there is also synchronous data fetching. I'm not sure whether
> KIO
> can do this. I've seen code for this using a raw tcp socket, but I'd
> rather
> have high-level http access to the data. Anyway, blocking is probably not
> an
> option here since it blocks the whole applet (or even plasma), right?
>
> Any hints are very welcome. Thanks in advance!
>
> Best whishes,
> Bernhard
> _______________________________________________
> Panel-devel mailing list
> Panel-devel at kde.org
> https://mail.kde.org/mailman/listinfo/panel-devel
>


Don't implement updateSource(QString).  Create a timer in your engine that
directs the HTTP data to be updated.  Once it returns the data, set the
required information using setData.  Once everything is updated call
checkForUpdates().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/panel-devel/attachments/20080307/785e9ece/attachment.html 


More information about the Panel-devel mailing list