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 Types

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 )

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

Parameters:

void  dataReq ( )

Call to ask for data (in put)

void  error ( int _errid, const QString &_text )

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

void  connected ()

Call in openConnection, if you reimplement it, when you're done. Currently unused.

void  finished ()

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

void  needSubURLData ()

Call 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:

void  statEntry ( const UDSEntry& _entry )

Call this once in stat()

void  listEntries ( const UDSEntryList& _entry )

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

bool  canResume ( unsigned long offset )

Call this at the beginning of put(), to give the size of the existing partial file, if there is one. The offset argument notifies the other job (the one that gets the data) about the offset to use. In this case, the boolean returns whether we can indeed resume or not (we can't if the protocol doing the get() doesn't support setting an offset)

void  canResume ()

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. This means: the data you'll get isn't the data you requested, but an error page (usually HTML) that describes an error.

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.

enum {QuestionYesNo = 1, WarningYesNo = 2, WarningContinueCancel = 3, WarningYesNoCancel = 4, Information = 5, SSLMessageBox = 6 }

int  messageBox ( int type, const QString &text, const QString &caption = QString::null, const QString &buttonYes = QString::null, const QString &buttonNo = QString::null )

Call this to show a message box from the slave (it will in fact be handled by kio_uiserver, so that the progress info dialog for the slave is hidden while this message box is shown)

Parameters:

Returns: a button code, as defined in KMessageBox, or 0 on communication error.

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:

void  setSubURL (const KURL&url)

[virtual]

Prepare slave for streaming operation

void  openConnection ()

[virtual]

Opens the connection (forced) Currently unused.

void  closeConnection ()

[virtual]

Closes the connection (forced) Currently unused.

void  get ( const KURL& url )

[virtual]

get, aka read.

Parameters:

void  put ( const KURL& url, int permissions, bool overwrite, bool resume )

[virtual]

put, aka write.

Parameters:

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:

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:

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:

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:

void  del ( const KURL &url, bool isfile)

[virtual]

Delete a file or directory.

Parameters:

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:

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:

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:

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

[protected const]

Checks whether the password daemon kdesud is up and running or can be started if it is not.

Returns: true if password daemon is/can be started successfully.

bool  openPassDlg ( const QString& msg, QString& user, QString& passwd, bool lockUserName = false )

[protected]

Prompts the user for Authentication info (login & password).

This function attempts to prompt the user for a password and returns true if the user complies (clicks OK) or false otherwise (clicks Cancel).

Exception: A call to this function can also fail, result in false, if the UIServer could not be started for some reason.

Parameters:

Returns: true on if successful, false otherwise

bool  checkCachedAuthentication ( const KURL& url, QString& user, QString& passwd, QString& realm, QString& extra, bool verify_path = true )

[protected]

Checks for any cached Authentication.

Parameters:

Returns: true if a cached Authentication is found

bool  checkCachedAuthentication ( const KURL& url, QString& user, QString& passwd)

[protected]

Same as above except in the number of arguments it takes.

This is a convenience method for protocols that have simple Authentication and do not require complex caching schemes such as ftp

Parameters:

Returns: true if cached Authentication if found

bool  cacheAuthentication ( const KURL& url, const QString& user, const QString& passwd, const QString& realm = QString::null, const QString& extra = QString::null )

[protected]

Caches Authentication information in kdesu daemon.

Authentication caching is based on the following criteria:

i.) The protocol as part of the key generation. This will reduce the chances of inadvertantly sending password to the incorrect server. Thus, http://www.foobar.org and ftp://www.foobar.org are treated as different request sites even if the same Authentication is assigned to the user for accessing both locations.

ii.) Cache different servers on the the same host but with different port numbers. For example, one might have multiple web-based admin tools, such as Webmin and SWAT, on the same server with different port numbers.

iii.) Use reference counting to keep track of all applications that are requesting password caching for the same location instead of storing duplicate enteries. The cached password can then be deleted when the last application referencing it is destroyed.

iv.) Allow redundant password caching for the same host based on heirarchy such that protocols, such as HTTP, can store Authentication info for multiple password protected content within the same site. For example, http://foo.org/foo/foo.html and http://foo.org/foo/bar/bar.html would fall under the same protection space while http://foo.org/foobar/foo.html would not and hence gets a different entry. Refer to RFC 2617 for further details.

Parameters:

Returns: true if Authentication was sucessfully cached

QString  createAuthCacheKey ( const KURL& url )

[protected]

Creates a basic key to be used to cache the password.

Parameters:

Returns: NULL if url is malformed, otherwise the generated key.

void  delCachedAuthentication ( const QString& grpname )

[protected]

Deletes any cached keys for the given group.

Parameters:

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:

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:

int  waitForAnswer ( int expected1, int expected2, QByteArray & data, int * pCmd = 0 )

[protected]

Wait for an answer to our request, until we get expected1 or expected2

Returns: the result from readData, as well as the cmd in *pCmd if set, and the data in data

QCString mProtocol

[protected]

Name of the protocol supported by this slave

Connection * m_pConnection

[protected]

void  sendMetaData ()

[protected]

Internal function to transmit meta data to the application.


Generated by: prospector@porky.devel.redhat.com on Fri Nov 3 09:58:58 2000, using kdoc 2.0a42.