Plasma::Service API review

Alex Merry huntedhacker at tiscali.co.uk
Thu May 15 16:15:15 CEST 2008


On Thursday 15 May 2008 14:47:36 Aaron J. Seigo wrote:
> On Thursday 15 May 2008, Alex Merry wrote:
> > - there's a protected setResult() method, but no obvious way for the
> > result to get anywhere.
>
> QVariant result() const;

Not sure how I missed that one.

It's interesting how the Service usage differs from the KJob usage.  As in 
classic KJob usage is to create a KJob with the relevant parameters, and then 
call start() or exec() (with no parameters).

The issue with doing it the Service way (where you create a Service, then ask 
for parameters for an operation, then call start(params)) is that I can see a 
lot of people getting crashes without knowing why, because they're not 
expecting the self-deletion.

The reason they won't expect it is because the API looks like it will hang 
around.  It feels like you should be able to use the same Service object for 
several different operations by doing:

Service* s = Service::load("foo");
connect(s, SIGNAL(result(KJob *)), this, SLOT(done(KJob *)));
KConfigGroup params = s->parameters("action1");
// set up params
s->start(params);
KConfigGroup moreparams = s->parameters("action2");
// set up moreparams
s->start(moreparams);

I'm not sure what the solution to this is, though.  Maybe to make the 
operation fixed at object creation time?  I can see that making Service return 
a KJob from a method rather than inherit it would make implementing services 
harder.

Alex


-- 
KDE: http://www.kde.org
Ubuntu/Kubuntu: http://www.ubuntu.org http://www.kubuntu.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080515/1d00afe4/attachment.pgp 


More information about the Panel-devel mailing list