kio Library API Documentation

KIO::SlaveBase Class Reference

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

#include <slavebase.h>

Inheritance diagram for KIO::SlaveBase:

Inheritance graph
[legend]
Collaboration diagram for KIO::SlaveBase:

Collaboration graph
[legend]
List of all members.

Public Types

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

Public Member Functions

 SlaveBase (const QCString &protocol, const QCString &pool_socket, const QCString &app_socket)
void exit ()
void dispatchLoop ()
void setConnection (Connection *connection)
Connectionconnection () const
void data (const QByteArray &data)
 Sends data in the slave to the job (i.e.

void dataReq ()
 Asks for data from the job.

void error (int _errid, const QString &_text)
 Call to signal an error.

void connected ()
 Call in openConnection, if you reimplement it, when you're done.

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.

void statEntry (const UDSEntry &_entry)
 Call this from stat() to express details about an object, the UDSEntry customarily contains the atoms describing file name, size, mimetype, etc.

void listEntries (const UDSEntryList &_entry)
 Call this in listDir, each time you have a bunch of entries to report.

bool canResume (KIO::filesize_t offset)
 Call this at the beginning of put(), to give the size of the existing partial file, if there is one.

void canResume ()
void totalSize (KIO::filesize_t _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 (KIO::filesize_t _bytes)
 Call this during get and copy, once in a while, to give some info about the current state.

void processedPercent (float percent)
 Only use this if you can't know in advance the size of the copied data.

void speed (unsigned long _bytes_per_second)
 Call this in get and copy, to give the current transfer speed, but only if it can't be calculated out of the size you passed to processedSize (in most cases you don't want to call it).

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.

void mimeType (const QString &_type)
 Call this in mimetype, when you know the mimetype.

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.

int messageBox (MessageBoxType 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).

void setMetaData (const QString &key, const QString &value)
 Sets meta-data to be send to the application before the first data() or finished() signal.

bool hasMetaData (const QString &key)
 Queries for the existance of a certain config/meta-data entry send by the application to the slave.

QString metaData (const QString &key)
 Queries for config/meta-data send by the application to the slave.

KConfigBaseconfig ()
 Returns a configuration object to query config/meta-data information from.

virtual void setHost (const QString &host, int port, const QString &user, const QString &pass)
 Set the host.

virtual void setSubURL (const KURL &url)
 Prepare slave for streaming operation.

virtual void openConnection ()
 Opens the connection (forced) When this function gets called the slave is operating in connection-oriented mode.

virtual void closeConnection ()
 Closes the connection (forced) Called when the application disconnects the slave to close any open network connections.

virtual void get (const KURL &url)
 get, aka read.

virtual void put (const KURL &url, int permissions, bool overwrite, bool resume)
 put, aka write.

virtual void stat (const KURL &url)
 Finds all details for one file or directory.

virtual void mimetype (const KURL &url)
 Finds mimetype for one file or directory.

virtual void listDir (const KURL &url)
 Lists the contents of path.

virtual void mkdir (const KURL &url, int permissions)
 Create a directory.

virtual void rename (const KURL &src, const KURL &dest, bool overwrite)
 Rename oldname into newname.

virtual void symlink (const QString &target, const KURL &dest, bool overwrite)
 Creates a symbolic link named dest, pointing to target, which may be a relative or an absolute path.

virtual void chmod (const KURL &url, int permissions)
 Change permissions on path The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD.

virtual void copy (const KURL &src, const KURL &dest, int permissions, bool overwrite)
 Copy src into dest.

virtual void del (const KURL &url, bool isfile)
 Delete a file or directory.

virtual void special (const QByteArray &)
 Used for any command that is specific to this slave (protocol) Examples are : HTTP POST, mount and unmount (kio_file).

virtual void multiGet (const QByteArray &)
 Used for multiple get.

virtual void slave_status ()
 Called to get the status of the slave.

virtual void reparseConfiguration ()
 Called by the scheduler to tell the slave that the configuration changed (i.e.

int connectTimeout ()
int proxyConnectTimeout ()
int responseTimeout ()
int readTimeout ()
void setTimeoutSpecialCommand (int timeout, const QByteArray &data=QByteArray())
 This function sets a timeout of timeout seconds and calls special(data) when the timeout occurs as if it was called by the application.

virtual bool dispatch ()
virtual void dispatch (int command, const QByteArray &data)
int readData (QByteArray &buffer)
 Read data send by the job, after a dataReq.

void listEntry (const UDSEntry &_entry, bool ready)
 internal function to be called by the slave.

void connectSlave (const QString &path)
 internal function to connect a slave to/ disconnect from either the slave pool or the application

void disconnectSlave ()
bool pingCacheDaemon () const
 Checks whether the password daemon kdesud is running or if it can be started if it is not.

bool openPassDlg (KIO::AuthInfo &info, const QString &errorMsg)
 Prompt the user for Authorization info (login & password).

bool openPassDlg (KIO::AuthInfo &info)
bool checkCachedAuthentication (AuthInfo &info)
 Checks for cached authentication based on parameters given by info.

bool cacheAuthentication (const AuthInfo &info)
 Explicitly store authentication information.

QString createAuthCacheKey (const KURL &url)
 Creates a basic key to be used to cache the password.

void sendAuthenticationKey (const QCString &gKey, const QCString &key, bool keep)
void delCachedAuthentication (const QString &key)
void setMultipleAuthCaching (bool enable)
 Setup support for multiple auth-info caching to a single server.

bool multipleAuthCaching () const
bool requestNetwork (const QString &host=QString::null)
 Used by the slave to check if it can connect to a given host.

void dropNetwork (const QString &host=QString::null)
 Used by the slave to withdraw a connection requested by requestNetwork.

DCOPClientdcopClient ()
 Return the dcop client used by this slave.

int waitForAnswer (int expected1, int expected2, QByteArray &data, int *pCmd=0)
 Wait for an answer to our request, until we get expected1 or expected2.

void sendMetaData ()
 Internal function to transmit meta data to the application.

bool wasKilled () const
 If your ioslave was killed by a signal, wasKilled() returns true.

void setKillFlag ()
 Internally used.


Static Public Member Functions

void sigsegv_handler (int)
void sigpipe_handler (int)

Public Attributes

QCString mProtocol
 Name of the protocol supported by this slave.

Connectionm_pConnection
MetaData mOutgoingMetaData
MetaData mIncomingMetaData

Protected Member Functions

virtual void virtual_hook (int id, void *data)

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.

Definition at line 44 of file slavebase.h.


Member Function Documentation

void SlaveBase::data const QByteArray data  ) 
 

Sends data in the slave to the job (i.e.

in get).

To signal end of data, simply send an empty QByteArray().

Parameters:
data the data read by the slave

Definition at line 354 of file slavebase.cpp.

References KIO::Connection::send(), and sendMetaData().

Referenced by canResume(), delCachedAuthentication(), dropNetwork(), error(), infoMessage(), listEntries(), messageBox(), mimeType(), processedSize(), redirection(), requestNetwork(), sendAuthenticationKey(), sendMetaData(), slaveStatus(), speed(), statEntry(), totalSize(), and warning().

void SlaveBase::dataReq  ) 
 

Asks for data from the job.

See also:
readData

Definition at line 363 of file slavebase.cpp.

References canResume(), and KIO::Connection::send().

void SlaveBase::error int  _errid,
const QString _text
 

Call to signal an error.

This also finishes the job, no need to call finished.

If the Error code is KIO::ERR_SLAVE_DEFINED then the _text should contain the complete translated text of of the error message. This message will be displayed in an KTextBrowser which allows rich text complete with hyper links. Email links will call the default mailer, "exec:/command arg1 arg2" will be forked and all other links will call the default browser.

See also:
KIO::Error

KTextBrowser

Parameters:
_errid the error code from KIO::Error
_text the rich text error message

Definition at line 374 of file slavebase.cpp.

References data(), and KIO::Connection::send().

Referenced by chmod(), copy(), del(), get(), listDir(), mkdir(), multiGet(), openConnection(), put(), rename(), setSubURL(), special(), stat(), and symlink().

void SlaveBase::connected  ) 
 

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

Definition at line 387 of file slavebase.cpp.

References KIO::Connection::send().

void SlaveBase::finished  ) 
 

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

Definition at line 394 of file slavebase.cpp.

References KIO::Connection::send(), and sendMetaData().

void SlaveBase::needSubURLData  ) 
 

Call to signal that data from the sub-URL is needed.

Definition at line 407 of file slavebase.cpp.

References KIO::Connection::send().

void SlaveBase::slaveStatus const QString host,
bool  connected
 

Used to report the status of the slave.

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

Definition at line 412 of file slavebase.cpp.

References data(), mProtocol, and KIO::Connection::send().

Referenced by slave_status().

void SlaveBase::statEntry const UDSEntry _entry  ) 
 

Call this from stat() to express details about an object, the UDSEntry customarily contains the atoms describing file name, size, mimetype, etc.

Parameters:
_entry The UDSEntry containing all of the object attributes.

Definition at line 583 of file slavebase.cpp.

References data(), KIO::Connection::send(), and KIO::UDSEntry.

void SlaveBase::listEntries const UDSEntryList _entry  ) 
 

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

Definition at line 633 of file slavebase.cpp.

References QValueList::begin(), QValueList::count(), data(), QValueList::end(), KStdAccel::end(), and KIO::Connection::send().

Referenced by listEntry().

bool SlaveBase::canResume KIO::filesize_t  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)

Definition at line 815 of file slavebase.cpp.

References data(), KIO::number(), KIO::Connection::send(), and waitForAnswer().

Referenced by dataReq().

void SlaveBase::totalSize KIO::filesize_t  _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.

Definition at line 427 of file slavebase.cpp.

References data(), and KIO::Connection::send().

void SlaveBase::processedSize KIO::filesize_t  _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.

Definition at line 443 of file slavebase.cpp.

References data(), and KIO::Connection::send().

void SlaveBase::processedPercent float  percent  ) 
 

Only use this if you can't know in advance the size of the copied data.

For example, if you're doing variable bitrate compression of the source.

STUB ! Currently unimplemented. Here now for binary compatibility.

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.

Definition at line 470 of file slavebase.cpp.

void SlaveBase::speed unsigned long  _bytes_per_second  ) 
 

Call this in get and copy, to give the current transfer speed, but only if it can't be calculated out of the size you passed to processedSize (in most cases you don't want to call it).

Definition at line 476 of file slavebase.cpp.

References data(), and KIO::Connection::send().

void SlaveBase::redirection const KURL _url  ) 
 

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

Definition at line 484 of file slavebase.cpp.

References data(), and KIO::Connection::send().

void SlaveBase::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.

Definition at line 490 of file slavebase.cpp.

References KIO::Connection::send().

void SlaveBase::mimeType const QString _type  ) 
 

Call this in mimetype, when you know the mimetype.

See mimetype about other ways to implement it.

Definition at line 507 of file slavebase.cpp.

References data(), KIO::Connection::read(), and KIO::Connection::send().

void SlaveBase::warning const QString msg  ) 
 

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

Definition at line 550 of file slavebase.cpp.

References data(), and KIO::Connection::send().

void SlaveBase::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.

Definition at line 556 of file slavebase.cpp.

References data(), and KIO::Connection::send().

int SlaveBase::messageBox MessageBoxType  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:
type type of message box: QuestionYesNo, WarningYesNo, WarningContinueCancel...
text Message string. May contain newlines.
caption Message box title.
buttonYes The text for the first button. The default is i18n("&Yes").
buttonNo The text for the second button. The default is i18n("&No"). Note: for ContinueCancel, buttonYes is the continue button and buttonNo is unused. and for Information, none is used.
Returns:
a button code, as defined in KMessageBox, or 0 on communication error.

Definition at line 798 of file slavebase.cpp.

References data(), KIO::Connection::send(), and waitForAnswer().

void SlaveBase::setMetaData const QString key,
const QString value
 

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

Definition at line 315 of file slavebase.cpp.

References KStdAccel::key().

bool SlaveBase::hasMetaData const QString key  ) 
 

Queries for the existance of a certain config/meta-data entry send by the application to the slave.

Definition at line 329 of file slavebase.cpp.

References KStdAccel::key().

QString SlaveBase::metaData const QString key  ) 
 

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

Definition at line 320 of file slavebase.cpp.

References KStdAccel::key().

Referenced by cacheAuthentication(), checkCachedAuthentication(), connectTimeout(), openPassDlg(), proxyConnectTimeout(), readTimeout(), and responseTimeout().

KConfigBase * SlaveBase::config  ) 
 

Returns a configuration object to query config/meta-data information from.

The application provides the slave with all configuration information relevant for the current protocol and host.

Definition at line 338 of file slavebase.cpp.

void SlaveBase::setHost const QString host,
int  port,
const QString user,
const QString pass
[virtual]
 

Set the host.

Parameters:
host 
port 
user 
pass Called directly by createSlave, this is why there is no equivalent in SlaveInterface, unlike the other methods.
This method is called whenever a change in host, port or user occurs.

Definition at line 687 of file slavebase.cpp.

void SlaveBase::setSubURL const KURL url  )  [virtual]
 

Prepare slave for streaming operation.

Definition at line 719 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::openConnection  )  [virtual]
 

Opens the connection (forced) When this function gets called the slave is operating in connection-oriented mode.

When a connection gets lost while the slave operates in connection oriented mode, the slave should report ERR_CONNECTION_BROKEN instead of reconnecting.

Definition at line 691 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::closeConnection  )  [virtual]
 

Closes the connection (forced) Called when the application disconnects the slave to close any open network connections.

When the slave was operating in connection-oriented mode, it should reset itself to connectionless (default) mode.

Definition at line 693 of file slavebase.cpp.

void SlaveBase::get const KURL url  )  [virtual]
 

get, aka read.

Parameters:
url the 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

Definition at line 703 of file slavebase.cpp.

References error(), and mProtocol.

Referenced by mimetype().

void SlaveBase::put const KURL url,
int  permissions,
bool  overwrite,
bool  resume
[virtual]
 

put, aka write.

Parameters:
path where to write the file (decoded)
permissions may be -1. In this case no special permission mode is set.
overwrite if true, any existing file will be overwritten. If the file indeed already exists, the slave should NOT apply the permissions change to it.
resume 

Definition at line 697 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::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.

Definition at line 695 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::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.

Definition at line 705 of file slavebase.cpp.

References get().

void SlaveBase::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.

Definition at line 701 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::mkdir const KURL url,
int  permissions
[virtual]
 

Create a directory.

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

Definition at line 715 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::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:
src where to move the file from
dest where to move the file to
overwrite if true, any existing file will be overwritten

Definition at line 707 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::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:
target The string that will become the "target" of the link (can be relative)
dest The symlink to create.
overwrite whether to automatically overwrite if the dest exists

Definition at line 709 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::chmod const KURL url,
int  permissions
[virtual]
 

Change permissions on path The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD.

Definition at line 717 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::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:
src where to copy the file from (decoded)
dest where to copy the file to (decoded)
permissions may be -1. In this case no special permission mode is set.
overwrite if true, any existing file will be overwritten

Definition at line 711 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::del const KURL url,
bool  isfile
[virtual]
 

Delete a file or directory.

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

Definition at line 713 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::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:
data packed 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.

Definition at line 699 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::multiGet const QByteArray  )  [virtual]
 

Used for multiple get.

Currently only used foir HTTP pielining support.

Parameters:
data packed data; Contains number of URLs to fetch, and for each URL the URL itself and its associated MetaData.

Definition at line 721 of file slavebase.cpp.

References error(), and mProtocol.

void SlaveBase::slave_status  )  [virtual]
 

Called to get the status of the slave.

Slave should respond by calling slaveStatus(...)

Definition at line 725 of file slavebase.cpp.

References slaveStatus().

void SlaveBase::reparseConfiguration  )  [virtual]
 

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

proxy settings) .

Definition at line 728 of file slavebase.cpp.

int SlaveBase::connectTimeout  ) 
 

Returns:
timeout value for connecting to remote host.

Definition at line 1146 of file slavebase.cpp.

References metaData(), and QString::toInt().

int SlaveBase::proxyConnectTimeout  ) 
 

Returns:
timeout value for connecting to proxy in secs.

Definition at line 1156 of file slavebase.cpp.

References metaData(), and QString::toInt().

int SlaveBase::responseTimeout  ) 
 

Returns:
timeout value for read from first data from remote host in seconds.

Definition at line 1167 of file slavebase.cpp.

References metaData(), and QString::toInt().

int SlaveBase::readTimeout  ) 
 

Returns:
timeout value for read from subsequent data from remote host in secs.

Definition at line 1178 of file slavebase.cpp.

References metaData(), and QString::toInt().

void SlaveBase::setTimeoutSpecialCommand int  timeout,
const QByteArray data = QByteArray()
 

This function sets a timeout of timeout seconds and calls special(data) when the timeout occurs as if it was called by the application.

A timeout can only occur when the slave is waiting for a command from the application.

Specifying a negative timeout cancels a pending timeout.

Only one timeout at a time is supported, setting a timeout cancels any pending timeout.

Since:
3.1

Definition at line 872 of file slavebase.cpp.

int SlaveBase::readData QByteArray buffer  ) 
 

Read data send by the job, after a dataReq.

Parameters:
buffer buffer where data is stored
Returns:
0 on end of data, > 0 bytes read < 0 error

Definition at line 865 of file slavebase.cpp.

References waitForAnswer().

void SlaveBase::listEntry const UDSEntry _entry,
bool  ready
 

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:
ready set to true after emitting all items. _entry is not used in this case

Definition at line 591 of file slavebase.cpp.

References QValueList::append(), QValueList::clear(), QValueList::count(), listEntries(), and KIO::UDSEntry.

void SlaveBase::connectSlave const QString path  ) 
 

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

Definition at line 298 of file slavebase.cpp.

References QFile::encodeName(), KIO::Connection::init(), and KIO::Connection::inited().

bool SlaveBase::pingCacheDaemon  )  const
 

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

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

Definition at line 1054 of file slavebase.cpp.

bool SlaveBase::openPassDlg KIO::AuthInfo info,
const QString errorMsg
 

Prompt the user for Authorization info (login & password).

Use this function to request authorization info from the the end user. You can also pass an errorMsg which explains why a previous authorisation attempt failed. For example to open an empty password dialog using default values:

KIO::AuthInfo authInfo; if ( openPassDlg( authInfo ) ) { printf( "Username: %s", authInfo.username.latin1() ); printf( "Password: %s", authInfo.password.latin1() ); }

You can also pre-set some values like the username before hand if it is known as well as the comment and caption to be displayed:

KIO::AuthInfo authInfo; authInfo.caption= "Acme Password Dialog"; authInfo.username= "Wile E. Coyote"; QString errorMsg = "You entered an incorrect password."; if ( openPassDlg( authInfo, errorMsg ) ) { printf( "Username: %s", authInfo.username.latin1() ); printf( "Password: %s", authInfo.password.latin1() ); }

NOTE: A call to this function can also fail and result in a return value of false, if the UIServer could not be started for whatever reason.

Parameters:
info See AuthInfo.
errorMsg Error message to show
Returns:
TRUE if user clicks on "OK", FALSE otherwsie.
Since:
3.1

Definition at line 753 of file slavebase.cpp.

References dcopClient(), KIO::AuthInfo::isModified(), QString::lower(), metaData(), QString::toLong(), and KIO::AuthInfo::username.

bool SlaveBase::checkCachedAuthentication AuthInfo info  ) 
 

Checks for cached authentication based on parameters given by info.

Use this function to check if any cached password exists for the URL given by info. If AuthInfo::realmValue is present and/or the AuthInfo::verifyPath flag is set, then they will also be factored in determining the presence of a cached password. Note that Auth::url is a required parameter when attempting to check for cached authorization info. Here is a simple example:

AuthInfo info; info.url = KURL("http://www.foobar.org/foo/bar"); info.username = "somename"; info.verifyPath = true; if ( !checkCachedAuthentication( info ) ) { if ( !openPassDlg(info) ) .... }

If the protocol allows multiple resources within the same location to be protected by different passwords, then to determine the correct password and send pre-emtively, i.e. before the other end requires it, you can use one or both of the following methods: set the unique identifier using AuthInfo::realmValue or require that a path match be performed using AuthInfo::verifyPath.

info.url = KURL("http://www.foobar.org/foo/bar"); info.verifyPath = true; info.realmValue = "unique_identifier";

NOTE: A call to this function will fail and return false, whenever the "kdesud" could not be started for whatever reason or an invalid URL is supplied.

Parameters:
See AuthInfo.
Returns:
TRUE if cached Authorization is found, false otherwise.

Definition at line 1072 of file slavebase.cpp.

References dcopClient(), KIO::AuthInfo::isModified(), metaData(), QString::toLong(), KURL::url(), and KIO::AuthInfo::url.

bool SlaveBase::cacheAuthentication const AuthInfo info  ) 
 

Explicitly store authentication information.

openPassDlg already stores password information automatically, you only need to call this function if you want to store authentication information that is different from the information returned by openPassDlg.

Definition at line 1121 of file slavebase.cpp.

References dcopClient(), metaData(), and QString::toLong().

QString SlaveBase::createAuthCacheKey const KURL url  ) 
 

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

Parameters:
url the url from which the key is supposed to be generated

Definition at line 1035 of file slavebase.cpp.

References KURL::host(), KURL::isMalformed(), KStdAccel::key(), QString::number(), KURL::port(), and KURL::protocol().

void SlaveBase::sendAuthenticationKey const QCString gKey,
const QCString key,
bool  keep
 

Deprecated:
Cache authentication information is now stored automatically by openPassDlg.

Definition at line 646 of file slavebase.cpp.

References data(), KStdAccel::key(), and KIO::Connection::send().

void SlaveBase::delCachedAuthentication const QString key  ) 
 

Deprecated:
Cache authentication information is now stored automatically by openPassDlg.

Definition at line 654 of file slavebase.cpp.

References data(), KStdAccel::key(), and KIO::Connection::send().

void SlaveBase::setMultipleAuthCaching bool  enable  ) 
 

Setup support for multiple auth-info caching to a single server.

Calling this function with the argument set to true will allow a user to work on multiple resources located under different accounts but on the same server without being re-prompted for authorization each time. Simply put if you have a "foo" and a "bar" account on a given machine at "foobar.com" and you log into this machine using both of the accounts, then the authorization information you supplied for both accounts will be cached. This is also true if you have N number of accounts and you logged into all of them. Otherwise, the default behavior is for the latest login will simply overwrite the previous one.

Parameters:
enable if true allow multiple auth-info caching.

Definition at line 1136 of file slavebase.cpp.

bool SlaveBase::multipleAuthCaching  )  const
 

Returns:
true if multiple auth-info caching is enabled.

Definition at line 1141 of file slavebase.cpp.

bool SlaveBase::requestNetwork const QString host = QString::null  ) 
 

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:
host tells 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.

Definition at line 562 of file slavebase.cpp.

References data(), KIO::Connection::send(), and waitForAnswer().

void SlaveBase::dropNetwork const QString host = QString::null  ) 
 

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.

Parameters:
host the host passed to requestNetwork
A slave should call this function every time it disconnect from a host.

Definition at line 577 of file slavebase.cpp.

References data(), and KIO::Connection::send().

DCOPClient * SlaveBase::dcopClient  ) 
 

Return the dcop client used by this slave.

Since:
3.1

Definition at line 226 of file slavebase.cpp.

Referenced by cacheAuthentication(), checkCachedAuthentication(), and openPassDlg().

int SlaveBase::waitForAnswer int  expected1,
int  expected2,
QByteArray data,
int *  pCmd = 0
 

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

Definition at line 837 of file slavebase.cpp.

References KIO::Connection::read().

Referenced by canResume(), messageBox(), readData(), and requestNetwork().

void SlaveBase::sendMetaData  ) 
 

Internal function to transmit meta data to the application.

Definition at line 343 of file slavebase.cpp.

References data(), and KIO::Connection::send().

Referenced by data(), and finished().

bool SlaveBase::wasKilled  )  const
 

If your ioslave was killed by a signal, wasKilled() returns true.

Check it regularly in lengthy functions (e.g. in get();) and return as fast as possible from this function if wasKilled() returns true. This will ensure that your slave destructor will be called correctly.

Since:
3.1

Definition at line 1188 of file slavebase.cpp.

void SlaveBase::setKillFlag  ) 
 

Internally used.

Definition at line 1193 of file slavebase.cpp.


Member Data Documentation

QCString KIO::SlaveBase::mProtocol
 

Name of the protocol supported by this slave.

Definition at line 757 of file slavebase.h.

Referenced by chmod(), copy(), del(), get(), listDir(), mkdir(), multiGet(), openConnection(), put(), rename(), setSubURL(), slaveStatus(), special(), stat(), and symlink().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:26:08 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001