KIO
workerbase.cpp
18WorkerBase::WorkerBase(const QByteArray &protocol, const QByteArray &poolSocket, const QByteArray &appSocket)
206 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_CONNECT));
215 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_STAT));
220 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_PUT));
225 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_SPECIAL));
230 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_LISTDIR));
235 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_GET));
240 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_OPEN));
245 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_READ));
250 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_WRITE));
255 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_SEEK));
260 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_TRUNCATE));
265 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_CLOSE));
275 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_RENAME));
280 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_SYMLINK));
285 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_COPY));
290 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_DEL));
295 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_MKDIR));
300 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_CHMOD));
305 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_SETMODIFICATIONTIME));
310 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_CHOWN));
315 return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(d->protocolName(), CMD_FILESYSTEMFREESPACE));
333int WorkerBase::messageBox(MessageBoxType type, const QString &text, const QString &title, const QString &primaryActionText, const QString &secondaryActionText)
345 return d->bridge.messageBox(text, static_cast<SlaveBase::MessageBoxType>(type), title, primaryActionText, secondaryActionText, dontAskAgainName);
480 return WorkerResult(std::make_unique<WorkerResultPrivate>(WorkerResultPrivate{false, _error, _errorString}));
485 return WorkerResult(std::make_unique<WorkerResultPrivate>(WorkerResultPrivate{true, 0, QString()}));
This class is intended to make it easier to prompt for, cache and retrieve authorization information.
Definition authinfo.h:50
virtual WorkerResult del(const QUrl &url, bool isfile)
Delete a file or directory.
Definition workerbase.cpp:288
virtual WorkerResult mimetype(const QUrl &url)
Finds MIME type for one file or directory.
Definition workerbase.cpp:268
virtual void reparseConfiguration()
Called by the scheduler to tell the worker that the configuration changed (i.e. proxy settings) .
Definition workerbase.cpp:323
bool wasKilled() const
If your ioworker was killed by a signal, wasKilled() returns true.
Definition workerbase.cpp:411
KConfigGroup * config()
Returns a configuration object to query config/meta-data information from.
Definition workerbase.cpp:80
KRemoteEncoding * remoteEncoding()
Returns an object that can translate remote filenames into proper Unicode forms.
Definition workerbase.cpp:95
int 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 worker.
Definition workerbase.cpp:333
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...
Definition workerbase.cpp:368
void totalSize(KIO::filesize_t _bytes)
Call this in get and copy, to give the total size of the file.
Definition workerbase.cpp:120
void statEntry(const UDSEntry &_entry)
Call this from stat() to express details about an object, the UDSEntry customarily contains the atoms...
Definition workerbase.cpp:181
virtual WorkerResult special(const QByteArray &data)
Used for any command that is specific to this worker (protocol).
Definition workerbase.cpp:223
virtual WorkerResult mkdir(const QUrl &url, int permissions)
Create a directory.
Definition workerbase.cpp:293
virtual WorkerResult stat(const QUrl &url)
Finds all details for one file or directory.
Definition workerbase.cpp:213
bool configValue(const QString &key, bool defaultValue) const
Returns a bool from the config/meta-data information.
Definition workerbase.cpp:65
void listEntry(const UDSEntry &entry)
It collects entries and emits them via listEntries when enough of them are there or a certain time fr...
Definition workerbase.cpp:186
void addTemporaryAuthorization(const QString &action)
Adds action to the list of PolicyKit actions which the worker is authorized to perform.
Definition workerbase.cpp:431
bool checkCachedAuthentication(AuthInfo &info)
Checks for cached authentication based on parameters given by info.
Definition workerbase.cpp:373
void warning(const QString &msg)
Call to signal a warning, to be displayed in a dialog box.
Definition workerbase.cpp:171
void workerStatus(const QString &host, bool connected)
Used to report the status of the worker.
Definition workerbase.cpp:110
void infoMessage(const QString &msg)
Call to signal a message, to be displayed if the application wants to, for instance in a status bar.
Definition workerbase.cpp:176
virtual WorkerResult symlink(const QString &target, const QUrl &dest, JobFlags flags)
Creates a symbolic link named dest, pointing to target, which may be a relative or an absolute path.
Definition workerbase.cpp:278
virtual WorkerResult chmod(const QUrl &url, int permissions)
Change permissions on url.
Definition workerbase.cpp:298
virtual WorkerResult listDir(const QUrl &url)
Lists the contents of url.
Definition workerbase.cpp:228
void listEntries(const UDSEntryList &_entry)
Call this in listDir, each time you have a bunch of entries to report.
Definition workerbase.cpp:191
int openPasswordDialog(KIO::AuthInfo &info, const QString &errorMsg=QString())
Prompt the user for Authorization info (login & password).
Definition workerbase.cpp:328
int waitForAnswer(int expected1, int expected2, QByteArray &data, int *pCmd=nullptr)
Wait for an answer to our request, until we get expected1 or expected2.
Definition workerbase.cpp:358
virtual void setHost(const QString &host, quint16 port, const QString &user, const QString &pass)
Set the host.
Definition workerbase.cpp:200
bool hasMetaData(const QString &key) const
Queries for the existence of a certain config/meta-data entry send by the application to the worker.
Definition workerbase.cpp:55
virtual WorkerResult fileSystemFreeSpace(const QUrl &url)
Get a filesystem's total and available space.
Definition workerbase.cpp:313
void setMetaData(const QString &key, const QString &value)
Sets meta-data to be send to the application before the first data() or finished() signal.
Definition workerbase.cpp:40
bool canResume(KIO::filesize_t offset)
Call this at the beginning of put(), to give the size of the existing partial file,...
Definition workerbase.cpp:353
void setIncomingMetaData(const KIO::MetaData &metaData)
Set the Incoming Meta Data This is only really useful if your worker wants to overwrite the metadata ...
Definition workerbase.cpp:493
bool cacheAuthentication(const AuthInfo &info)
Caches info in a persistent storage like KWallet.
Definition workerbase.cpp:378
QMap< QString, QVariant > mapConfig() const
Returns a map to query config/meta-data information from.
Definition workerbase.cpp:60
virtual WorkerResult chown(const QUrl &url, const QString &owner, const QString &group)
Change ownership of url.
Definition workerbase.cpp:308
QString metaData(const QString &key) const
Queries for config/meta-data send by the application to the worker.
Definition workerbase.cpp:45
void sendAndKeepMetaData()
Internal function to transmit meta data to the application.
Definition workerbase.cpp:90
PrivilegeOperationStatus requestPrivilegeOperation(const QString &operationDetails)
Checks with job if privilege operation is allowed.
Definition workerbase.cpp:426
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...
Definition workerbase.cpp:145
int readData(QByteArray &buffer)
Read data sent by the job, after a dataReq.
Definition workerbase.cpp:363
void mimeType(const QString &_type)
Call this in mimetype() and in get(), when you know the MIME type.
Definition workerbase.cpp:161
void data(const QByteArray &data)
Sends data in the worker to the job (i.e. in get).
Definition workerbase.cpp:100
void sendMetaData()
Internal function to transmit meta data to the application.
Definition workerbase.cpp:85
virtual WorkerResult copy(const QUrl &src, const QUrl &dest, int permissions, JobFlags flags)
Copy src into dest.
Definition workerbase.cpp:283
virtual WorkerResult rename(const QUrl &src, const QUrl &dest, JobFlags flags)
Rename oldname into newname.
Definition workerbase.cpp:273
void processedSize(KIO::filesize_t _bytes)
Call this during get and copy, once in a while, to give some info about the current state.
Definition workerbase.cpp:125
virtual WorkerResult setModificationTime(const QUrl &url, const QDateTime &mtime)
Sets the modification time for @url.
Definition workerbase.cpp:303
virtual WorkerResult put(const QUrl &url, int permissions, JobFlags flags)
put, i.e. write data into a file.
Definition workerbase.cpp:218
virtual WorkerResult open(const QUrl &url, QIODevice::OpenMode mode)
open.
Definition workerbase.cpp:238
void connectWorker(const QString &path)
internal function to connect a worker to/ disconnect from either the worker pool or the application
Definition workerbase.cpp:30
The result of a worker call When using the Result type always mark the function Q_REQUIRED_RESULT to ...
Definition workerbase.h:36
QString errorString() const
The localized error description if applicable.
Definition workerbase.cpp:473
static WorkerResult fail(int _error=KIO::ERR_UNKNOWN, const QString &_errorString=QString())
Constructs a failure results.
Definition workerbase.cpp:478
Allows encoding and decoding properly remote filenames into Unicode.
Definition kremoteencoding.h:37
KIOCORE_EXPORT QString unsupportedActionErrorString(const QString &protocol, int cmd)
Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...
Definition slavebase.cpp:849
KIOCORE_EXPORT CopyJob * move(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
Moves a file or directory src to the given destination dest.
Definition copyjob.cpp:2657
QList< UDSEntry > UDSEntryList
A directory listing is a list of UDSEntry instances.
Definition udsentry.h:379
typedef OpenMode
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:37 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:37 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.