IOSlaves

Introduction

In KDE's infrastructure, IOSlaves handle the transfer of data between applications and remote servers using common protocols such as http and ftp, but also for more mundane protocols like the file protocol for local files. Many of the mainstream protocols provided in the standard KDE distribution are implemented in C++, although some, like the finger IOSlave, rely on support scripts to handle various aspects of communication with remote servers. Since PyKDE provides Python implementations (or wrappers) for the relevant classes in the kio library, it is possible to write IOSlaves almost completely in Python; a simple C++ handling function is only required for dynamic linking purposes and to set up the interpreter.

Much of the documentation describing the creation of IOSlaves is, naturally, written to assist the C++ programmer by providing examples of the appropriate classes in use. When read alongside some of the distributed examples in the kdebase package of the KDE distribution, these tutorials provide most of the information required to write an IOSlave in Python "from scratch". However, some aspects of their operation would benefit from further description so it is useful to take this opportunity, when translating the material for a new audience, to try and provide clear and concise documentation to complement existing material. Note that I am not a implentor of IOSlaves in C++ so there may be scope for future additions and corrections to this document from KDE experts.

Requirements

A working IOSlave needs the following resources:

Additionally, a Python IOSlave requires a place to store the Python source code and possibly storage for any packages which are not situated in the Python library directory.

Examples

Two examples are provided to demonstrate the possibilities allowed by writing IOSlaves in Python. Each share a fair amount of common code, although the sources of data used by each differ greatly.

Bookmarks

This example presents the user's bookmarks for Konqueror as a filesystem and allows limited manipulation of the contents. Two versions of the IOSlave are provided: the most recent uses Qt's XML library to interpret the bookmarks file.

An older version which uses Python's xml.dom.minidom module is also provided for comparison. There are probably functional differences between the two versions.

Sprites

Using data obtained through a Python module, possibly involving a compiled C extension, this example enables Acorn (or RISC OS) Spritefiles to be displayed in Konqueror as a read-only filesystem. This allows each image stored in the file to be accessed individually and, since they are represented as PNG format files, they are automatically displayed as thumbnails by the standard thumbnail generators.

You will need to have installed the spritefile module to be able to use this IOSlave; this can be found at

    http://www.boddie.org.uk/david/Projects/Python/Spritefile/