class SlaveBase

There are two classes that specifies the protocol between application (job) and kioslave. More...

Full nameKIO::SlaveBase
Definition#include <slavebase.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Protected Methods

Protected Members


Detailed Description

There are two classes that specifies the protocol between application (job) and kioslave. SlaveInterface is the class to use on the application end, SlaveBase is the one to use on the slave end.

Slave implementations should simply inherit SlaveBase

A call to foo() results in a call to slotFoo() on the other end.

void  data ( const QByteArray &data )

Emit to send data in the slave (i.e. in get).

Parameters:
datathe data read by the slave Send an empty QByteArray() to signal end of data.

void  dataReq ( )

Emit to ask for data (in put)

void  error ( int _errid, const QString &_text )

Emit to signal an error. This also finishes the job, no need to call finished.

void  connected ()

Emit in openConnection, if you reimplement it, when you're done.

void  finished ()

Emit to signal successful completion of any command (besides openConnection and closeConnection)

void  slaveStatus (const QString &host, bool connected)

Used to report the status of the slave.

Parameters:
hostthe slave is currently connected to. (Should be empty if not connected)
connectedWhether an actual network connection exists.

void  statEntry ( const UDSEntry& _entry )

Emit this once in stat()

void  listEntries ( const UDSEntryList& _entry )

Emit this in listDir, each time you have a bunch of entries to report.

void  renamed ( const QString &_new )

???? Is this still necessary?

void  canResume ( bool _resume )

???? Is this still necessary?

void  setHost (const QString& host, int port, const QString& user, const QString& pass)

[virtual]

Set the host

Parameters:
pass Called directly by createSlave, this is why there is no equivalent in SlaveInterface, unlike the other methods.

void  openConnection ()

[virtual]

Opens the connection (forced)

void  closeConnection ()

[virtual]

Closes the connection (forced)

void  get ( const QString& path, const QString& query, bool reload )

[virtual]

get, aka read.

Parameters:
paththe file to retrieve (decoded)
queryan optionnal query (the part after the '?' in the URL)
reloadif true, make sure to get an up to date version The slave emits the data through data

void  put ( const QString& path, int permissions, bool overwrite, bool resume)

[virtual]

put, aka write.

Parameters:
pathwhere to write the file (decoded)
permissionsmay be -1. In this case no special permission mode is set.
overwriteif true, any existing file will be overwritten
resume

void  stat ( const QString & )

[virtual]

Finds all details for one file or directory. The information returned is the same as what listDir returns, but only for one file or directory.

void  mimetype ( const QString& path )

[virtual]

Finds mimetype for one file or directory.

This method should either emit 'mimetype' or it should send a block of data big enough to be able to determine the mimetype.

void  listDir ( const QString& path )

[virtual]

Lists the contents of path. The slave should emit ERR_CANNOT_ENTER_DIRECTORY if it doesn't exist, if we don't have enough permissions, or if it is a file

void  mkdir ( const QString& path, int permissions )

[virtual]

Create a directory

Parameters:
pathpath to the directory to create
permissionsthe permissions to set after creating the directory (-1 if no permissions to be set) The slave emits ERR_COULD_NOT_MKDIR if failure.

void  rename ( const QString& src, const QString& dest, bool overwrite )

[virtual]

Rename oldname into newname. If the slave returns an error ERR_UNSUPPORTED_ACTION, the job will ask for copy + del instead.

Parameters:
srcwhere to move the file from (decoded)
destwhere to move the file to (decoded)
overwriteif true, any existing file will be overwritten

void  chmod ( const QString& path, int permissions )

[virtual]

Change permissions on path The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD

void  copy ( const QString &src, const QString &dest, int permissions, bool overwrite )

[virtual]

Copy src into dest. If the slave returns an error ERR_UNSUPPORTED_ACTION, the job will ask for get + put instead.

Parameters:
srcwhere to copy the file from (decoded)
destwhere to copy the file to (decoded)
permissionsmay be -1. In this case no special permission mode is set.
overwriteif true, any existing file will be overwritten

void  del ( const QString &path, bool isfile)

[virtual]

Delete a file or directory.

Parameters:
pathfile/directory to delete
isfileif true, a file should be deleted. if false, a directory should be deleted.

void  special ( const QByteArray & )

[virtual]

Used for any command that is specific to this slave (protocol) Examples are : HTTP POST, mount and unmount (kio_file)

Parameters:
datapacked data; the meaning is completely dependent on the slave, but usually starts with an int for the command number. Document your slave's commands, at least in its header file.

void  slave_status ()

[virtual]

Called to get the status of the slave. Slave should respond by calling slaveStatus(...)

void  sigsegv_handler (int)

[static]

int  readData ( QByteArray &buffer)

Read data send by the job

Parameters:
bufferbuffer where data is stored

Returns: 0 on end of data, > 0 bytes read < 0 error

void  listEntry ( const UDSEntry& _entry, bool ready)

[protected]

internal function to be called by the slave. It collects entries and emits them via listEntries when enough of them are there or a certain time frame exceeded (to make sure the app gets some items in time but not too many items one by one as this will cause a drastic performance penalty

void  connectSlave (const QString& path)

[protected]

internal function to connect a slave to/ disconnect from either the slave pool or the application

QCString mProtocol

[protected]

Name of the protocol supported by this slave


Generated by: dfaure@faure on Sun Mar 26 14:24:43 2000, using kdoc 2.0a35.