KIO::SlaveBase

Search for usage in LXR

#include <KIO/SlaveBase>

Public Types

enum  ButtonCode {
  Ok = 1 , Cancel = 2 , PrimaryAction = 3 , SecondaryAction = 4 ,
  Continue = 5
}
 
enum  MessageBoxType {
  QuestionTwoActions = 1 , WarningTwoActions = 2 , WarningContinueCancel = 3 , WarningTwoActionsCancel = 4 ,
  Information = 5 , WarningContinueCancelDetailed = 10
}
 

Public Member Functions

 SlaveBase (const QByteArray &protocol, const QByteArray &pool_socket, const QByteArray &app_socket)
 
void addTemporaryAuthorization (const QString &action)
 
MetaData allMetaData () const
 
bool cacheAuthentication (const AuthInfo &info)
 
void canResume ()
 
bool canResume (KIO::filesize_t offset)
 
bool checkCachedAuthentication (AuthInfo &info)
 
virtual void chmod (const QUrl &url, int permissions)
 
virtual void chown (const QUrl &url, const QString &owner, const QString &group)
 
virtual void close ()
 
virtual void closeConnection ()
 
KConfigGroupconfig ()
 
bool configValue (const QString &key, bool defaultValue) const
 
QString configValue (const QString &key, const QString &defaultValue=QString()) const
 
int configValue (const QString &key, int defaultValue) const
 
void connected ()
 
void connectSlave (const QString &path)
 
int connectTimeout ()
 
virtual void copy (const QUrl &src, const QUrl &dest, int permissions, JobFlags flags)
 
void data (const QByteArray &data)
 
void dataReq ()
 
virtual void del (const QUrl &url, bool isfile)
 
void disconnectSlave ()
 
virtual void dispatch (int command, const QByteArray &data)
 
void dispatchLoop ()
 
virtual void dispatchOpenCommand (int command, const QByteArray &data)
 
void error (int _errid, const QString &_text)
 
void errorPage ()
 
void exit ()
 
void finished ()
 
virtual void get (const QUrl &url)
 
bool hasMetaData (const QString &key) const
 
void infoMessage (const QString &msg)
 
virtual void listDir (const QUrl &url)
 
void listEntries (const UDSEntryList &_entry)
 
void listEntry (const UDSEntry &entry)
 
void lookupHost (const QString &host)
 
QMap< QString, QVariantmapConfig () const
 
int messageBox (const QString &text, MessageBoxType type, const QString &title=QString(), const QString &primaryActionText=QString(), const QString &secondaryActionText=QString(), const QString &dontAskAgainName=QString())
 
int messageBox (MessageBoxType type, const QString &text, const QString &title=QString(), const QString &primaryActionText=QString(), const QString &secondaryActionText=QString())
 
QString metaData (const QString &key) const
 
void mimeType (const QString &_type)
 
virtual void mimetype (const QUrl &url)
 
virtual void mkdir (const QUrl &url, int permissions)
 
virtual void open (const QUrl &url, QIODevice::OpenMode mode)
 
virtual void openConnection ()
 
void opened ()
 
int openPasswordDialogV2 (KIO::AuthInfo &info, const QString &errorMsg=QString())
 
void position (KIO::filesize_t _pos)
 
void processedPercent (float percent)
 
void processedSize (KIO::filesize_t _bytes)
 
int proxyConnectTimeout ()
 
virtual void put (const QUrl &url, int permissions, JobFlags flags)
 
virtual void read (KIO::filesize_t size)
 
int readData (QByteArray &buffer)
 
int readTimeout ()
 
void redirection (const QUrl &_url)
 
KRemoteEncodingremoteEncoding ()
 
virtual void rename (const QUrl &src, const QUrl &dest, JobFlags flags)
 
virtual void reparseConfiguration ()
 
PrivilegeOperationStatus requestPrivilegeOperation (const QString &operationDetails)
 
int responseTimeout ()
 
virtual void seek (KIO::filesize_t offset)
 
void sendAndKeepMetaData ()
 
void sendMetaData ()
 
virtual void setHost (const QString &host, quint16 port, const QString &user, const QString &pass)
 
void setKillFlag ()
 
virtual void setLinkDest (const QUrl &url, const QString &target)
 
void setMetaData (const QString &key, const QString &value)
 
virtual void setModificationTime (const QUrl &url, const QDateTime &mtime)
 
void setTimeoutSpecialCommand (int timeout, const QByteArray &data=QByteArray())
 
virtual void slave_status ()
 
void slaveStatus (const QString &host, bool connected)
 
virtual void special (const QByteArray &data)
 
void speed (unsigned long _bytes_per_second)
 
int sslError (const QVariantMap &sslData)
 
virtual void stat (const QUrl &url)
 
void statEntry (const UDSEntry &_entry)
 
virtual void symlink (const QString &target, const QUrl &dest, JobFlags flags)
 
void totalSize (KIO::filesize_t _bytes)
 
void truncated (KIO::filesize_t _length)
 
int waitForAnswer (int expected1, int expected2, QByteArray &data, int *pCmd=nullptr)
 
int waitForHostInfo (QHostInfo &info)
 
void warning (const QString &msg)
 
bool wasKilled () const
 
virtual void write (const QByteArray &data)
 
void written (KIO::filesize_t _bytes)
 

Protected Types

enum  VirtualFunctionId { AppConnectionMade = 0 , GetFileSystemFreeSpace = 1 , Truncate = 2 }
 

Protected Member Functions

virtual void virtual_hook (int id, void *data)
 

Protected Attributes

MetaData mIncomingMetaData
 
MetaData mOutgoingMetaData
 
QByteArray mProtocol
 

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.

Note that a kioslave doesn't have a Qt event loop. When idle, it's waiting for a command on the socket that connects it to the application. So don't expect a kioslave to react to D-Bus signals for instance. KIOSlaves are short-lived anyway, so any kind of watching or listening for notifications should be done elsewhere, for instance in a kded module (see kio_desktop's desktopnotifier.cpp for an example).

If a kioslave needs a Qt event loop within the implementation of one method, e.g. to wait for an asynchronous operation to finish, that is possible, using QEventLoop.

Deprecated
Since 5.96, use WorkerBase.

Definition at line 55 of file slavebase.h.

Member Enumeration Documentation

◆ ButtonCode

Button codes.

Should be kept in sync with KMessageBox::ButtonCode

Enumerator
PrimaryAction 
Since
5.100
SecondaryAction 
Since
5.100

Definition at line 270 of file slavebase.h.

◆ MessageBoxType

Type of message box.

Should be kept in sync with KMessageBox::DialogType.

Enumerator
QuestionTwoActions 
Since
5.100
WarningTwoActions 
Since
5.100
WarningTwoActionsCancel 
Since
5.100

Definition at line 257 of file slavebase.h.

◆ VirtualFunctionId

enum KIO::SlaveBase::VirtualFunctionId
protected

Definition at line 942 of file slavebase.h.

Constructor & Destructor Documentation

◆ SlaveBase()

SlaveBase::SlaveBase ( const QByteArray & protocol,
const QByteArray & pool_socket,
const QByteArray & app_socket )

Definition at line 269 of file slavebase.cpp.

◆ ~SlaveBase()

SlaveBase::~SlaveBase ( )
virtual

Definition at line 313 of file slavebase.cpp.

Member Function Documentation

◆ addTemporaryAuthorization()

void SlaveBase::addTemporaryAuthorization ( const QString & action)

Adds action to the list of PolicyKit actions which the slave is authorized to perform.

Parameters
actionthe PolicyKit action
Since
5.45

Definition at line 1572 of file slavebase.cpp.

◆ allMetaData()

MetaData SlaveBase::allMetaData ( ) const

for ForwardingSlaveBase Contains all metadata (but no config) sent by the application to the slave.

Definition at line 416 of file slavebase.cpp.

◆ cacheAuthentication()

bool SlaveBase::cacheAuthentication ( const AuthInfo & info)

Caches info in a persistent storage like KWallet.

Note that calling openPasswordDialogV2 does not store passwords automatically for you (and has not since kdelibs 4.7).

Here is a simple example of how to use cacheAuthentication:

AuthInfo info;
info.url = QUrl("https://www.foobar.org/foo/bar");
info.username = "somename";
info.verifyPath = true;
if ( !checkCachedAuthentication( info ) ) {
int errorCode = openPasswordDialogV2(info);
if (!errorCode) {
if (info.keepPassword) { // user asked password be save/remembered
}
}
}
This class is intended to make it easier to prompt for, cache and retrieve authorization information.
Definition authinfo.h:50
bool verifyPath
Flag that, if set, indicates whether a path match should be performed when requesting for cached auth...
Definition authinfo.h:202
QUrl url
The URL for which authentication is to be stored.
Definition authinfo.h:100
bool keepPassword
Flag to indicate the persistence of the given password.
Definition authinfo.h:222
QString username
This is required for caching.
Definition authinfo.h:105
int openPasswordDialogV2(KIO::AuthInfo &info, const QString &errorMsg=QString())
Prompt the user for Authorization info (login & password).
bool cacheAuthentication(const AuthInfo &info)
Caches info in a persistent storage like KWallet.
bool checkCachedAuthentication(AuthInfo &info)
Checks for cached authentication based on parameters given by info.
Parameters
infoSee AuthInfo.
Returns
true if info was successfully cached.

Definition at line 1407 of file slavebase.cpp.

◆ canResume() [1/2]

void SlaveBase::canResume ( )

Call this at the beginning of get(), if the "range-start" metadata was set and returning byte ranges is implemented by this protocol.

Definition at line 622 of file slavebase.cpp.

◆ canResume() [2/2]

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 1050 of file slavebase.cpp.

◆ checkCachedAuthentication()

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 and/or AuthInfo::verifyPath flag is specified, 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 = QUrl("https://www.foobar.org/foo/bar");
info.username = "somename";
info.verifyPath = true;
{
int errorCode = openPasswordDialogV2(info);
....
}
Parameters
infoSee AuthInfo.
Returns
true if cached Authorization is found, false otherwise.

Definition at line 1357 of file slavebase.cpp.

◆ chmod()

void SlaveBase::chmod ( const QUrl & url,
int permissions )
virtual

Change permissions on url.

The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD

Definition at line 957 of file slavebase.cpp.

◆ chown()

void SlaveBase::chown ( const QUrl & url,
const QString & owner,
const QString & group )
virtual

Change ownership of url.

The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHOWN

Definition at line 965 of file slavebase.cpp.

◆ close()

void SlaveBase::close ( )
virtual

close.

See also
KIO::FileJob::close()

Definition at line 925 of file slavebase.cpp.

◆ closeConnection()

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 886 of file slavebase.cpp.

◆ config()

KConfigGroup * 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.

Note
Since 5.64 prefer to use mapConfig() or one of the configValue(...) overloads.
Todo
Find replacements for the other current usages of this method.

Definition at line 452 of file slavebase.cpp.

◆ configValue() [1/3]

bool SlaveBase::configValue ( const QString & key,
bool defaultValue ) const

Returns a bool from the config/meta-data information.

Since
5.64

Definition at line 437 of file slavebase.cpp.

◆ configValue() [2/3]

QString SlaveBase::configValue ( const QString & key,
const QString & defaultValue = QString() ) const

Returns a QString from the config/meta-data information.

Since
5.64

Definition at line 447 of file slavebase.cpp.

◆ configValue() [3/3]

int SlaveBase::configValue ( const QString & key,
int defaultValue ) const

Returns an int from the config/meta-data information.

Since
5.64

Definition at line 442 of file slavebase.cpp.

◆ connected()

void SlaveBase::connected ( )

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

Definition at line 554 of file slavebase.cpp.

◆ connectSlave()

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 384 of file slavebase.cpp.

◆ connectTimeout()

int SlaveBase::connectTimeout ( )
Returns
timeout value for connecting to remote host.

Definition at line 1416 of file slavebase.cpp.

◆ copy()

void SlaveBase::copy ( const QUrl & src,
const QUrl & dest,
int permissions,
JobFlags flags )
virtual

Copy src into dest.

By default, copy() is only called when copying a file from yourproto://host/path to yourproto://host/otherpath.

If you set copyFromFile=true then copy() will also be called when moving a file from file:///path to yourproto://host/otherpath. Otherwise such a copy would have to be done the slow way (get+put). See also KProtocolManager::canCopyFromFile().

If you set copyToFile=true then copy() will also be called when moving a file from yourproto: to file:. See also KProtocolManager::canCopyToFile().

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

If the slave returns an error ERR_FILE_ALREADY_EXIST, the job will ask for a different destination filename.

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, and the owner and group permissions are not preserved.
flagsWe support Overwrite here

Don't forget to set the modification time of dest to be the modification time of src.

Definition at line 941 of file slavebase.cpp.

◆ data()

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
datathe data read by the slave

Definition at line 493 of file slavebase.cpp.

◆ dataReq()

void SlaveBase::dataReq ( )

Asks for data from the job.

See also
readData

Definition at line 499 of file slavebase.cpp.

◆ del()

void SlaveBase::del ( const QUrl & url,
bool isfile )
virtual

Delete a file or directory.

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

By default, del() on a directory should FAIL if the directory is not empty. However, if metadata("recurse") == "true", then the slave can do a recursive deletion. This behavior is only invoked if the slave specifies deleteRecursive=true in its protocol file.

Definition at line 945 of file slavebase.cpp.

◆ disconnectSlave()

void SlaveBase::disconnectSlave ( )

Definition at line 397 of file slavebase.cpp.

◆ dispatch()

void SlaveBase::dispatch ( int command,
const QByteArray & data )
virtual

Definition at line 1118 of file slavebase.cpp.

◆ dispatchLoop()

void SlaveBase::dispatchLoop ( )

Definition at line 320 of file slavebase.cpp.

◆ dispatchOpenCommand()

void SlaveBase::dispatchOpenCommand ( int command,
const QByteArray & data )
virtual

Definition at line 1367 of file slavebase.cpp.

◆ error()

void SlaveBase::error ( int _errid,
const QString & _text )

Call to signal an error.

This also finishes the job, so you must not call finished() after calling this.

If the error code is KIO::ERR_SLAVE_DEFINED then the _text should contain the complete translated text of of the error message.

For all other error codes, _text should match the corresponding error code. Usually, _text is a file or host name, or the error which was passed from the server.
For example, for KIO::ERR_DOES_NOT_EXIST, _text may only be the file or folder which does not exist, nothing else. Otherwise, this would break error strings generated by KIO::buildErrorString().
If you have to add more details than what the standard error codes provide, you'll need to use KIO::ERR_SLAVE_DEFINED. For a complete list of what _text should contain for each error code, look at the source of KIO::buildErrorString().

You can add rich text markup to the message, the places where the error message will be displayed are rich text aware.

See also
KIO::Error
KIO::buildErrorString
Parameters
_erridthe error code from KIO::Error
_textthe rich text error message

Definition at line 515 of file slavebase.cpp.

◆ errorPage()

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 694 of file slavebase.cpp.

◆ exit()

void SlaveBase::exit ( )

Terminate the slave by calling the destructor and then exit()

Definition at line 751 of file slavebase.cpp.

◆ finished()

void SlaveBase::finished ( )

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

Do not call this after calling error().

Definition at line 559 of file slavebase.cpp.

◆ get()

void SlaveBase::get ( const QUrl & 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 should first "emit" the MIME type by calling mimeType(), and then "emit" the data using the data() method.

The reason why we need get() to emit the MIME type is: when pasting a URL in krunner, or konqueror's location bar, we have to find out what is the MIME type of that URL. Rather than doing it with a call to mimetype(), then the app or part would have to do a second request to the same server, this is done like this: get() is called, and when it emits the MIME type, the job is put on hold and the right app or part is launched. When that app or part calls get(), the slave is magically reused, and the download can now happen. All with a single call to get() in the slave. This mechanism is also described in KIO::get().

Definition at line 905 of file slavebase.cpp.

◆ hasMetaData()

bool SlaveBase::hasMetaData ( const QString & key) const

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

Definition at line 421 of file slavebase.cpp.

◆ infoMessage()

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 771 of file slavebase.cpp.

◆ listDir()

void SlaveBase::listDir ( const QUrl & url)
virtual

Lists the contents of url.

The slave should emit ERR_CANNOT_ENTER_DIRECTORY if it doesn't exist, if we don't have enough permissions. You should not list files if the path in url is empty, but redirect to a non-empty path instead.

Definition at line 901 of file slavebase.cpp.

◆ listEntries()

void SlaveBase::listEntries ( const UDSEntryList & _entry)

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

Parameters
_entryThe UDSEntry containing all of the object attributes.

Definition at line 809 of file slavebase.cpp.

◆ listEntry()

void SlaveBase::listEntry ( const UDSEntry & entry)

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
entryThe UDSEntry containing all of the object attributes.
Since
5.0

Definition at line 783 of file slavebase.cpp.

◆ lookupHost()

void SlaveBase::lookupHost ( const QString & host)

Internally used.

Definition at line 1511 of file slavebase.cpp.

◆ mapConfig()

QMap< QString, QVariant > SlaveBase::mapConfig ( ) const

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

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

Use configValue() as shortcut.

Since
5.64

Definition at line 432 of file slavebase.cpp.

◆ messageBox() [1/2]

int SlaveBase::messageBox ( const QString & text,
MessageBoxType type,
const QString & title = QString(),
const QString & primaryActionText = QString(),
const QString & secondaryActionText = QString(),
const QString & dontAskAgainName = QString() )

Call this to show a message box from the slave.

Parameters
textMessage string. May contain newlines.
typetype of message box: QuestionTwoActions, WarningTwoActions, WarningContinueCancel...
titleMessage box title.
primaryActionTextthe text for the first button. Ignored for type Information & SSLMessageBox.
secondaryActionTextthe text for the second button. Ignored for type WarningContinueCancel, WarningContinueCancelDetailed, Information & SSLMessageBox.
dontAskAgainNamethe name used to store result from 'Do not ask again' checkbox.
Returns
a button code, as defined in ButtonCode, or 0 on communication error.

Definition at line 1017 of file slavebase.cpp.

◆ messageBox() [2/2]

int SlaveBase::messageBox ( MessageBoxType type,
const QString & text,
const QString & title = QString(),
const QString & primaryActionText = QString(),
const QString & secondaryActionText = QString() )

Call this to show a message box from the slave.

Parameters
typetype of message box: QuestionTwoActions, WarningTwoActions, WarningContinueCancel...
textMessage string. May contain newlines.
titleMessage box title.
primaryActionTextthe text for the first button. Ignored for type Information & SSLMessageBox.
secondaryActionTextthe text for the second button. Ignored for type WarningContinueCancel, WarningContinueCancelDetailed, Information & SSLMessageBox.
Returns
a button code, as defined in ButtonCode, or 0 on communication error.

Definition at line 1012 of file slavebase.cpp.

◆ metaData()

QString SlaveBase::metaData ( const QString & key) const

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

Definition at line 407 of file slavebase.cpp.

◆ mimeType()

void SlaveBase::mimeType ( const QString & _type)

Call this in mimetype() and in get(), when you know the MIME type.

See mimetype() about other ways to implement it.

Definition at line 709 of file slavebase.cpp.

◆ mimetype()

void SlaveBase::mimetype ( const QUrl & url)
virtual

Finds MIME type 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 MIME type.

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

Definition at line 929 of file slavebase.cpp.

◆ mkdir()

void SlaveBase::mkdir ( const QUrl & url,
int permissions )
virtual

Create a directory.

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

Definition at line 953 of file slavebase.cpp.

◆ open()

void SlaveBase::open ( const QUrl & url,
QIODevice::OpenMode mode )
virtual

open.

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.
modesee QIODevice::OpenMode

Definition at line 909 of file slavebase.cpp.

◆ openConnection()

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. The user is expected to disconnect the slave in the error handler.

Definition at line 882 of file slavebase.cpp.

◆ opened()

void SlaveBase::opened ( )

open succeeds

See also
open()

Definition at line 508 of file slavebase.cpp.

◆ openPasswordDialogV2()

int SlaveBase::openPasswordDialogV2 ( KIO::AuthInfo & info,
const QString & errorMsg = QString() )

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

Use this function to request authorization information from the end user. You can also pass an error message which explains why a previous authorization attempt failed. Here is a very simple example:

KIO::AuthInfo authInfo;
int errorCode = openPasswordDialogV2(authInfo);
if (!errorCode) {
qDebug() << QLatin1String("User: ") << authInfo.username;
qDebug() << QLatin1String("Password: not displayed here!");
} else {
error(errorCode, QString());
}
void error(int _errid, const QString &_text)
Call to signal an error.

You can also preset some values like the username, caption or comment as follows:

KIO::AuthInfo authInfo;
authInfo.caption = i18n("Acme Password Dialog");
authInfo.username = "Wile E. Coyote";
QString errorMsg = i18n("You entered an incorrect password.");
int errorCode = openPasswordDialogV2(authInfo, errorMsg);
[...]
QString caption
The text to displayed in the title bar of the password prompting dialog.
Definition authinfo.h:132
QString i18n(const char *text, const TYPE &arg...)
Note
You should consider using checkCachedAuthentication() to see if the password is available in kpasswdserver before calling this function.
A call to this function can fail and return false, if the password server could not be started for whatever reason.
This function does not store the password information automatically (and has not since kdelibs 4.7). If you want to store the password information in a persistent storage like KWallet, then you MUST call cacheAuthentication.
See also
checkCachedAuthentication
Parameters
infoSee AuthInfo.
errorMsgError message to show
Returns
a KIO error code: NoError (0), KIO::USER_CANCELED, or other error codes.

Definition at line 981 of file slavebase.cpp.

◆ position()

void SlaveBase::position ( KIO::filesize_t _pos)

Definition at line 665 of file slavebase.cpp.

◆ processedPercent()

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 677 of file slavebase.cpp.

◆ processedSize()

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 636 of file slavebase.cpp.

◆ proxyConnectTimeout()

int SlaveBase::proxyConnectTimeout ( )
Returns
timeout value for connecting to proxy in secs.

Definition at line 1427 of file slavebase.cpp.

◆ put()

void SlaveBase::put ( const QUrl & url,
int permissions,
JobFlags flags )
virtual

put, i.e. write data into a file.

Parameters
urlwhere to write the file
permissionsmay be -1. In this case no special permission mode is set.
flagsWe support Overwrite here. Hopefully, we're going to support Resume in the future, too. If the file indeed already exists, the slave should NOT apply the permissions change to it. The support for resuming using .part files is done by calling canResume().

IMPORTANT: Use the "modified" metadata in order to set the modification time of the file.

See also
canResume()

Definition at line 893 of file slavebase.cpp.

◆ read()

void SlaveBase::read ( KIO::filesize_t size)
virtual

read.

Parameters
sizethe requested amount of data to read
See also
KIO::FileJob::read()

Definition at line 913 of file slavebase.cpp.

◆ readData()

int SlaveBase::readData ( QByteArray & buffer)

Read data sent by the job, after a dataReq.

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

Definition at line 1096 of file slavebase.cpp.

◆ readTimeout()

int SlaveBase::readTimeout ( )
Returns
timeout value for read from subsequent data from remote host in secs.

Definition at line 1449 of file slavebase.cpp.

◆ redirection()

void SlaveBase::redirection ( const QUrl & _url)

Call this to signal a redirection.

The job will take care of going to that url.

Definition at line 688 of file slavebase.cpp.

◆ remoteEncoding()

KRemoteEncoding * SlaveBase::remoteEncoding ( )

Returns an object that can translate remote filenames into proper Unicode forms.

This encoding can be set by the user.

Definition at line 483 of file slavebase.cpp.

◆ rename()

void SlaveBase::rename ( const QUrl & src,
const QUrl & dest,
JobFlags flags )
virtual

Rename oldname into newname.

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

Important: the slave must implement the logic "if the destination already exists, error ERR_DIR_ALREADY_EXIST or ERR_FILE_ALREADY_EXIST". For performance reasons no stat is done in the destination before hand, the slave must do it.

By default, rename() is only called when renaming (moving) from yourproto://host/path to yourproto://host/otherpath.

If you set renameFromFile=true then rename() will also be called when moving a file from file:///path to yourproto://host/otherpath. Otherwise such a move would have to be done the slow way (copy+delete). See KProtocolManager::canRenameFromFile() for more details.

If you set renameToFile=true then rename() will also be called when moving a file from yourproto: to file:. See KProtocolManager::canRenameToFile() for more details.

Parameters
srcwhere to move the file from
destwhere to move the file to
flagsWe support Overwrite here

Definition at line 933 of file slavebase.cpp.

◆ reparseConfiguration()

void SlaveBase::reparseConfiguration ( )
virtual

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

Definition at line 975 of file slavebase.cpp.

◆ requestPrivilegeOperation()

PrivilegeOperationStatus SlaveBase::requestPrivilegeOperation ( const QString & operationDetails)

Checks with job if privilege operation is allowed.

Returns
privilege operation status.
See also
PrivilegeOperationStatus
Since
5.66

Definition at line 1544 of file slavebase.cpp.

◆ responseTimeout()

int SlaveBase::responseTimeout ( )
Returns
timeout value for read from first data from remote host in seconds.

Definition at line 1438 of file slavebase.cpp.

◆ seek()

void SlaveBase::seek ( KIO::filesize_t offset)
virtual

seek.

Parameters
offsetthe requested amount of data to read
See also
KIO::FileJob::read()

Definition at line 921 of file slavebase.cpp.

◆ sendAndKeepMetaData()

void SlaveBase::sendAndKeepMetaData ( )

Internal function to transmit meta data to the application.

Like sendMetaData() but m_outgoingMetaData will not be cleared. This method is mainly useful in code that runs before the slave is connected to its final job.

Definition at line 474 of file slavebase.cpp.

◆ sendMetaData()

void SlaveBase::sendMetaData ( )

Internal function to transmit meta data to the application.

m_outgoingMetaData will be cleared; this means that if the slave is for example put on hold and picked up by a different KIO::Job later the new job will not see the metadata sent before. See kio/DESIGN.krun for an overview of the state progression of a job/slave.

Warning
calling this method may seriously interfere with the operation of KIO which relies on the presence of some metadata at some points in time. You should not use it if you are not familiar with KIO and not before the slave is connected to the last job before returning to idle state.

Definition at line 468 of file slavebase.cpp.

◆ setHost()

void SlaveBase::setHost ( const QString & host,
quint16 port,
const QString & user,
const QString & pass )
virtual

Set the host.

Called directly by createWorker, 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 832 of file slavebase.cpp.

◆ setKillFlag()

void SlaveBase::setKillFlag ( )

Internally used.

Definition at line 1465 of file slavebase.cpp.

◆ setLinkDest()

void SlaveBase::setLinkDest ( const QUrl & url,
const QString & target )
virtual

Change the destination of a symlink.

Parameters
urlthe url of the symlink to modify
targetthe new destination (target) of the symlink

Definition at line 949 of file slavebase.cpp.

◆ setMetaData()

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 402 of file slavebase.cpp.

◆ setModificationTime()

void SlaveBase::setModificationTime ( const QUrl & url,
const QDateTime & mtime )
virtual

Sets the modification time for url.

For instance this is what CopyJob uses to set mtime on dirs at the end of a copy. It could also be used to set the mtime on any file, in theory. The usual implementation on unix is to call utime(path, &myutimbuf). The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_SETTIME

Definition at line 961 of file slavebase.cpp.

◆ setTimeoutSpecialCommand()

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.

Definition at line 1103 of file slavebase.cpp.

◆ slave_status()

void SlaveBase::slave_status ( )
virtual

Called to get the status of the slave.

Slave should respond by calling slaveStatus(...)

Definition at line 970 of file slavebase.cpp.

◆ slaveStatus()

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

Definition at line 614 of file slavebase.cpp.

◆ special()

void SlaveBase::special ( const QByteArray & data)
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.

Definition at line 897 of file slavebase.cpp.

◆ speed()

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 682 of file slavebase.cpp.

◆ sslError()

int SlaveBase::sslError ( const QVariantMap & sslData)

Definition at line 1036 of file slavebase.cpp.

◆ stat()

void SlaveBase::stat ( const QUrl & 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. Call statEntry() after creating the appropriate UDSEntry for this url.

You can use the "details" metadata to optimize this method to only do as much work as needed by the application. By default details is 2 (all details wanted, including modification time, size, etc.), details==1 is used when deleting: we don't need all the information if it takes too much time, no need to follow symlinks etc. details==0 is used for very simple probing: we'll only get the answer "it's a file or a directory (or a symlink), or it doesn't exist".

Definition at line 889 of file slavebase.cpp.

◆ statEntry()

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, MIME type, etc.

Parameters
_entryThe UDSEntry containing all of the object attributes.

Definition at line 777 of file slavebase.cpp.

◆ symlink()

void SlaveBase::symlink ( const QString & target,
const QUrl & dest,
JobFlags flags )
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.
flagsWe support Overwrite here

Definition at line 937 of file slavebase.cpp.

◆ totalSize()

void SlaveBase::totalSize ( KIO::filesize_t _bytes)

Call this in get and copy, to give the total size of the file.

Definition at line 627 of file slavebase.cpp.

◆ truncated()

void SlaveBase::truncated ( KIO::filesize_t _length)
Since
5.66

Definition at line 671 of file slavebase.cpp.

◆ virtual_hook()

void SlaveBase::virtual_hook ( int id,
void * data )
protectedvirtual

Definition at line 1490 of file slavebase.cpp.

◆ waitForAnswer()

int SlaveBase::waitForAnswer ( int expected1,
int expected2,
QByteArray & data,
int * pCmd = nullptr )

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 1069 of file slavebase.cpp.

◆ waitForHostInfo()

int SlaveBase::waitForHostInfo ( QHostInfo & info)

Internally used.

Definition at line 1517 of file slavebase.cpp.

◆ warning()

void SlaveBase::warning ( const QString & msg)

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

Definition at line 765 of file slavebase.cpp.

◆ wasKilled()

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.

Definition at line 1460 of file slavebase.cpp.

◆ write()

void SlaveBase::write ( const QByteArray & data)
virtual

write.

Parameters
datathe data to write
See also
KIO::FileJob::write()

Definition at line 917 of file slavebase.cpp.

◆ written()

void SlaveBase::written ( KIO::filesize_t _bytes)

Definition at line 659 of file slavebase.cpp.

Member Data Documentation

◆ mIncomingMetaData

MetaData KIO::SlaveBase::mIncomingMetaData
protected

Definition at line 940 of file slavebase.h.

◆ mOutgoingMetaData

MetaData KIO::SlaveBase::mOutgoingMetaData
protected

Definition at line 939 of file slavebase.h.

◆ mProtocol

QByteArray KIO::SlaveBase::mProtocol
protected

Name of the protocol supported by this slave.

Definition at line 937 of file slavebase.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.