KJob::putOnHold() and KIO::Scheduler::publishSlaveOnHold()

View: New views
1 Messages — Rating Filter:   Alert me  

KJob::putOnHold() and KIO::Scheduler::publishSlaveOnHold()

by Bugzilla from bart.cerneels@kde.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm trying to make the podcast download functionality in Amarok
better. I've been using KIO::storedGet() because it was the easiest to
implement. Unfortunately that also means the entire file is stored in
memory until completed and some users are rightfully complaining [1].

Right now I'm trying to use KIO::file_copy, which downloads to partial
files and supports resuming. Both of these features are critical.
Unfortunately FileCopyJob doesn't have the redirected() signal which I
need to get the original filename on the server (almost all enclosure
url's are query based redirects used for download statistics).

So the api doc of KIO::get() said this:

"Special case: if you want to determine the mimetype of the file
first, and then read it with the appropriate component, you can still
use a KIO::get() directly. When that job emits the mimeType signal,
(which is guaranteed to happen before it emits any data), put the job
on hold: job->putOnHold(); KIO::Scheduler::publishSlaveOnHold(); and
forget about the job. The next time someone does a KIO::get() on the
same URL (even in another process) this job will be resumed. This
saves KIO from doing two requests to the server."

I thought that meant I can start a KIO::get(), put it on hold and then
the TransferJob is reused by KIO::file_copy and I can still get the
signals from the get. Guess I was to optimistic?!?

I've put the relevant code here: http://pastebin.org/49332

Hope someone can tell me if/how this is supposed to work.

Greets
Bart

[1] http://bugs.kde.org/show_bug.cgi?id=209937
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<