
Now that your application is all prepped for using ioslaves, you can actually start using them!
To work with the ioslaves at a client level, you need only get a pointer to the correct type of "job" via the operation you want to accomplish. For instance, for simple things like creating or removing directories, you will get a pointer to a KIO::SimpleJob. If you are downloading or uploading data, then you'll want KIO::TransferJob. Listing the contents of a directory (local or remote) will require a KIO::ListJob.
The basic procedure is something like this:
Find the correct operation that you want to accomplish in in the kio/job.h header file. It will tell you which type Job is used.
Call that particular operation and get a pointer to the resulting job.
Connect all of the signals (events) that you are interested in to some local slots (callbacks).
Process the resulting response in your slots.
An example looks like so:
KIO::CopyJob *job = KIO::copy("http://www.granroth.org", "file:/home/kurt");
connect(job, SIGNAL(result(KIO::Job *)),
this, SLOT(slotResult(KIO::Job *)));
|
This will copy the web page from my website to my local directory... but the destination could just has easily been a remote FTP site. The ioslaves don't care if files are local or remote. When the ioslave is done copying, it will send you the result to your slotResult() function.