class SlaveBase

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

Full nameKIO::SlaveBase
Definition#include <slavebase.h>
Inherited byTCPSlaveBase
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.

 SlaveBase ( const QCString &protocol, const QCString &pool_socket, const QCString &app_socket)

SlaveBase ()

[virtual]

void  dispatchLoop ()

void  setConnection ( Connection* connection )

Connection * connection ()

[const]

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  needSubURLData ()

Emit to signal that data from the sub-URL is needed

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  canResume ( bool _resume )

???? Is this still necessary?

void  totalSize ( unsigned long _bytes )

Call this in get and copy, to give the total size of the file Call in listDir too, when you know the total number of items.

void  processedSize ( unsigned long _bytes )

Call this during get and copy, once in a while, to give some info about the current state. Don't emit it in listDir, listEntries speaks for itself.

void  speed ( unsigned long _bytes_per_second )

Call this in get and copy, to give the current transfer speed. Usually worked out as processed_size / ( t - t_start )

void  redirection ( const KURL &_url )

Call this to signal a redirection The job will take care of going to that url.

void  errorPage ()

"Tell that we will only get an error page here." ? ## FIXME

void  mimeType ( const QString &_type )

Call this in mimetype, when you know the mimetype. See mimetype about other ways to implement it.

void  gettingFile ( const QString &_file )

void  warning ( const QString &msg )

Call to signal a warning, to be displayed in a dialog box.

void  infoMessage ( const QString &msg )

Call to signal a message, to be displayed if the application wants to, for instance in a status bar. Usual examples are "connecting to host xyz", etc.

bool  openPassDlg ( const QString& , QString& , QString& , const QString& = QString::null )

Call this when requesting for a login and password.

This function is only different from the above only because it takes one more extra argument, the name of the host, so that any authorization can kept around for a whole session.

Parameters:
headand i18n'ed message to explain the dialog box
useruser name, in and out
passpassword, in and out
keythe string to be used to cache the password.

Returns: true on ok, false on cancel

void  setMetaData (const QString &key, const QString &value)

Sets meta-data to be send to the application before the first data() or finished() signal.

QString  metaData (const QString &key)

Queries for meta-data send by the application to the slave.

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

[virtual]

Set the host

This method is called whenever a change in host, port or user occurs.

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

void  setSubURL (const KURL&url)

[virtual]

Prepare slave for streaming operation

void  openConnection ()

[virtual]

Opens the connection (forced)

void  closeConnection ()

[virtual]

Closes the connection (forced)

void  get ( const KURL& url )

[virtual]

get, aka read.

Parameters:
urlthe full url for this request. Host, port and user of the URL can be assumed to be the same as in the last setHost() call. The slave emits the data through data

void  put ( const KURL& url, 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 KURL& url )

[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 KURL& url )

[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.

If the slave doesn't reimplement it, a get will be issued, i.e. the whole file will be downloaded before determining the mimetype on it - this is obviously not a good thing in most cases.

void  listDir ( const KURL& url )

[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 It should also emit totalFiles as soon as it knows how many files it will list.

void  mkdir ( const KURL&url, 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 KURL& src, const KURL& 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
destwhere to move the file to
overwriteif true, any existing file will be overwritten

void  symlink ( const QString& target, const KURL& dest, bool overwrite )

[virtual]

Creates a symbolic link named dest, pointing to target, which may be a relative or an absolute path.

Parameters:
targetThe string that will become the "target" of the link (can be relative)
destThe symlink to create.
overwritewhether to automatically overwrite if the dest exists

void  chmod ( const KURL& url, int permissions )

[virtual]

Change permissions on path The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD

void  copy ( const KURL &src, const KURL &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 KURL &url, 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  reparseConfiguration ()

[virtual]

Called by the scheduler to tell the slave that the configuration changed (i.e. proxy settings) .

void  sigsegv_handler (int)

[static]

void  sigpipe_handler (int)

[static]

bool  dispatch ()

[virtual]

void  dispatch ( int command, const QByteArray &data )

[virtual]

int  readData ( QByteArray &buffer )

Read data send by the job, after a dataReq

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)

Parameters:
readyset to true after emitting all items. _entry is not used in this case

void  connectSlave (const QString& path)

[protected]

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

void  disconnectSlave ()

[protected]

bool  checkCachedAuthentication (QString& user, QString& passwd, int& auth_type, QString& valid_path, const QString& realm)

[protected]

internal function that slaves use to see if there is any cached authentication entries

void  cacheAuthentication (const KURL& url, const QString& user, const QString& password, int auth_type)

[protected]

internal function to store authentication entries

bool  requestNetwork (const QString& host = QString::null)

[protected]

Used by the slave to check if it can connect to a given host. This should be called where the slave is ready to do a ::connect() on a socket. For each call to requestNetwork must exist a matching call to dropNetwork, or the system will stay online until KNetMgr gets closed (or the SlaveBase gets destructed)!

If KNetMgr is not running, then this is a no-op and returns true

Parameters:
hosttells the netmgr the host the slave wants to connect to. As this could also be a proxy, we can't just take the host currenctly connected to (but that's the default value)

Returns: true in theorie, the host is reachable false the system is offline and the host is in a remote network.

void  dropNetwork (const QString& host = QString::null)

[protected]

Used by the slave to withdraw a connection requested by requestNetwork. This function cancels the last call to requestNetwork. If a client uses more than one internet connection, it must use dropNetwork(host) to stop each request.

If KNetMgr is not running, then this is a no-op.

A slave should call this function every time it disconnect from a host.

Parameters:
hostthe host passed to requestNetwork

QCString mProtocol

[protected]

Name of the protocol supported by this slave

Connection * m_pConnection

[protected]


Generated by: prospector@porky.devel.redhat.com on Thu Aug 24 05:36:06 2000, using kdoc 2.0a36.