The K Desktop Environment

Chapter 4. Using IOSlaves

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:

4.1. Simple Example

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.