Problems managing KIO::Jobs

David Faure faure at kde.org
Sun Dec 4 09:58:35 UTC 2016


On lundi 14 novembre 2016 15:23:01 CET A. Bikadorov wrote:
> 1. Creating and immediately suspending a job does not work as expected. E.g.
> after
> > KIO::Job job = KIO::copy(urls, dest, flags);
> > bool result = job->suspend(); // returns true
> > bool result2 = job->isSuspended(); // returns true
> 
> the file copy operation is still starting. All progress signals
> (description(), percent(), ...), are omitted until result() and finished()
> are emitted. I'm sure this is a bug and can report it but would also like
> to know a workaround to continue implementing a "job queue" (i.e. the user
> decides when a job is started).

Indeed suspend() before starting wasn't implemented. It was only used
internally for the bitburger protocol in CopyJob.

I have now at least implemented suspend()-before-start() in SimpleJob
and FileCopyJob, in 
https://commits.kde.org/kio/91fd82cc595a07549ef9da85079415497a7780ae
(this won't be in KF 5.29, it's for 5.30)

So the above would work with KIO::file_copy, at least.
KIO::copy is a different story, a CopyJob has no kioslave on its own, but 
basically manages a state machine, so suspending anywhere in there and 
resuming where we left off seems a bit tricky. The special case of suspending
before starting is easy to implement though... done:
https://commits.kde.org/kio/84d5c6c71d2f0e37ef4cc9c4349531ba088e2ae6

I'm afraid I can't provide you with any workarounds, other than not creating 
the job until it should run.

> 2. Similar to (1) DropJobs are never emitting any signals until finished().
> It must be possible somehow to monitor the progress of copy or move
> operations because the notification widget does this. But I could not
> figure out how plasma-workspace/kuiserver does this.

I suppose kuiserver gets the signals from the subjob, while you're listening 
to the DropJob itself.

It should be easy to forward the signals in 
DropJobPrivate::doCopyToDirectory().

Feel free to make a patch (or report a bug, but a patch is preferred ;) ).

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5



More information about the Kde-frameworks-devel mailing list