KIO::ForwardingWorkerBase
#include <KIO/ForwardingWorkerBase>
Public Member Functions | |
ForwardingWorkerBase (const QByteArray &protocol, const QByteArray &poolSocket, const QByteArray &appSocket) | |
WorkerResult | chmod (const QUrl &url, int permissions) override |
WorkerResult | copy (const QUrl &src, const QUrl &dest, int permissions, JobFlags flags) override |
WorkerResult | del (const QUrl &url, bool isfile) override |
WorkerResult | get (const QUrl &url) override |
WorkerResult | listDir (const QUrl &url) override |
WorkerResult | mimetype (const QUrl &url) override |
WorkerResult | mkdir (const QUrl &url, int permissions) override |
WorkerResult | put (const QUrl &url, int permissions, JobFlags flags) override |
WorkerResult | rename (const QUrl &src, const QUrl &dest, JobFlags flags) override |
WorkerResult | setModificationTime (const QUrl &url, const QDateTime &mtime) override |
WorkerResult | stat (const QUrl &url) override |
WorkerResult | symlink (const QString &target, const QUrl &dest, JobFlags flags) override |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () const const |
Public Member Functions inherited from KIO::WorkerBase | |
WorkerBase (const QByteArray &protocol, const QByteArray &poolSocket, const QByteArray &appSocket) | |
void | addTemporaryAuthorization (const QString &action) |
MetaData | allMetaData () const |
virtual void | appConnectionMade () |
bool | cacheAuthentication (const AuthInfo &info) |
void | canResume () |
bool | canResume (KIO::filesize_t offset) |
bool | checkCachedAuthentication (AuthInfo &info) |
virtual WorkerResult | chown (const QUrl &url, const QString &owner, const QString &group) |
virtual WorkerResult | close () |
virtual void | closeConnection () |
KConfigGroup * | config () |
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 |
int | connectTimeout () |
void | connectWorker (const QString &path) |
void | data (const QByteArray &data) |
void | dataReq () |
void | disconnectWorker () |
void | dispatchLoop () |
void | errorPage () |
void | exit () |
virtual WorkerResult | fileSystemFreeSpace (const QUrl &url) |
bool | hasMetaData (const QString &key) const |
void | infoMessage (const QString &msg) |
void | listEntries (const UDSEntryList &_entry) |
void | listEntry (const UDSEntry &entry) |
void | lookupHost (const QString &host) |
QMap< QString, QVariant > | mapConfig () 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 WorkerResult | open (const QUrl &url, QIODevice::OpenMode mode) |
virtual WorkerResult | openConnection () |
int | openPasswordDialog (KIO::AuthInfo &info, const QString &errorMsg=QString()) |
void | position (KIO::filesize_t _pos) |
void | processedSize (KIO::filesize_t _bytes) |
int | proxyConnectTimeout () |
virtual WorkerResult | read (KIO::filesize_t size) |
int | readData (QByteArray &buffer) |
int | readTimeout () |
void | redirection (const QUrl &_url) |
KRemoteEncoding * | remoteEncoding () |
virtual void | reparseConfiguration () |
PrivilegeOperationStatus | requestPrivilegeOperation (const QString &operationDetails) |
int | responseTimeout () |
virtual WorkerResult | seek (KIO::filesize_t offset) |
void | sendAndKeepMetaData () |
void | sendMetaData () |
virtual void | setHost (const QString &host, quint16 port, const QString &user, const QString &pass) |
void | setIncomingMetaData (const KIO::MetaData &metaData) |
void | setMetaData (const QString &key, const QString &value) |
void | setTimeoutSpecialCommand (int timeout, const QByteArray &data=QByteArray()) |
virtual WorkerResult | special (const QByteArray &data) |
void | speed (unsigned long _bytes_per_second) |
int | sslError (const QVariantMap &sslData) |
void | statEntry (const UDSEntry &_entry) |
void | totalSize (KIO::filesize_t _bytes) |
virtual WorkerResult | truncate (KIO::filesize_t size) |
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 | worker_status () |
void | workerStatus (const QString &host, bool connected) |
virtual WorkerResult | write (const QByteArray &data) |
void | written (KIO::filesize_t _bytes) |
Protected Types | |
enum | UDSEntryCreationMode { UDSEntryCreationInStat , UDSEntryCreationInListDir } |
Protected Member Functions | |
virtual void | adjustUDSEntry (KIO::UDSEntry &entry, UDSEntryCreationMode creationMode) const |
QUrl | processedUrl () const |
QUrl | requestedUrl () const |
virtual bool | rewriteUrl (const QUrl &url, QUrl &newURL)=0 |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
Public Types inherited from QObject | |
typedef | QObjectList |
Public Types inherited from KIO::WorkerBase | |
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 } |
Properties inherited from QObject | |
objectName | |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Detailed Description
This class should be used as a base for KIO workers acting as a forwarder to other KIO workers.
It has been designed to support only local filesystem like KIO workers.
If the resulting KIO worker should be a simple proxy, you only need to implement the ForwardingWorkerBase::rewriteUrl() method.
For more advanced behavior, the classic KIO worker methods should be reimplemented, because their default behavior in this class is to forward using the ForwardingWorkerBase::rewriteUrl() method.
A possible code snippet for an advanced stat() behavior would look like this in the child class:
Of course in this case, you surely need to reimplement listDir() and get() accordingly.
If you want view on directories to be correctly refreshed when something changes on a forwarded URL, you'll need a companion kded module to emit the KDirNotify Files*() D-Bus signals.
- Since
- 5.101
Member Enumeration Documentation
◆ UDSEntryCreationMode
|
protected |
Enumerator | |
---|---|
UDSEntryCreationInStat | The entry is created during a stat operation. |
UDSEntryCreationInListDir | The entry is created during a listDir operation. |
Definition at line 108 of file forwardingworkerbase.h.
Constructor & Destructor Documentation
◆ ForwardingWorkerBase()
KIO::ForwardingWorkerBase::ForwardingWorkerBase | ( | const QByteArray & | protocol, |
const QByteArray & | poolSocket, | ||
const QByteArray & | appSocket ) |
Definition at line 79 of file forwardingworkerbase.cpp.
Member Function Documentation
◆ adjustUDSEntry()
|
protectedvirtual |
Adjusts a UDSEntry before it's sent in the reply to the KIO worker endpoint.
This is the default implementation working in most cases, but sometimes you could make use of more forwarding black magic (for example dynamically transform any desktop file into a fake directory...)
- Parameters
-
entry the UDSEntry to adjust creationMode the operation for which this entry is created
Definition at line 102 of file forwardingworkerbase.cpp.
◆ chmod()
|
overridevirtual |
Change permissions on url
.
The worker emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD
Reimplemented from KIO::WorkerBase.
Definition at line 264 of file forwardingworkerbase.cpp.
◆ copy()
|
overridevirtual |
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 worker returns an error ERR_UNSUPPORTED_ACTION, the job will ask for get + put instead.
If the worker returns an error ERR_FILE_ALREADY_EXIST, the job will ask for a different destination filename.
- 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, and the owner and group permissions are not preserved. flags We support Overwrite here
Don't forget to set the modification time of dest
to be the modification time of src
.
Reimplemented from KIO::WorkerBase.
Definition at line 288 of file forwardingworkerbase.cpp.
◆ del()
|
overridevirtual |
Delete a file or directory.
- Parameters
-
url file/directory to delete isfile if 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 worker can do a recursive deletion. This behavior is only invoked if the worker specifies deleteRecursive=true in its protocol file.
Reimplemented from KIO::WorkerBase.
Definition at line 306 of file forwardingworkerbase.cpp.
◆ get()
|
overridevirtual |
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 worker 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 worker is magically reused, and the download can now happen. All with a single call to get() in the worker. This mechanism is also described in KIO::get().
Reimplemented from KIO::WorkerBase.
Definition at line 160 of file forwardingworkerbase.cpp.
◆ listDir()
|
overridevirtual |
Lists the contents of url
.
The worker 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.
Reimplemented from KIO::WorkerBase.
Definition at line 208 of file forwardingworkerbase.cpp.
◆ mimetype()
|
overridevirtual |
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 worker 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.
Reimplemented from KIO::WorkerBase.
Definition at line 196 of file forwardingworkerbase.cpp.
◆ mkdir()
|
overridevirtual |
Create a directory.
- Parameters
-
url path to the directory to create permissions the permissions to set after creating the directory (-1 if no permissions to be set) The worker emits ERR_CANNOT_MKDIR if failure.
Reimplemented from KIO::WorkerBase.
Definition at line 220 of file forwardingworkerbase.cpp.
◆ processedUrl()
|
protected |
Return the URL being processed by the KIO worker Only access it inside adjustUDSEntry()
Definition at line 150 of file forwardingworkerbase.cpp.
◆ put()
|
overridevirtual |
put, i.e. write data into a file.
- Parameters
-
url where to write the file permissions may be -1. In this case no special permission mode is set. flags We support Overwrite here. Hopefully, we're going to support Resume in the future, too. If the file indeed already exists, the worker 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()
Reimplemented from KIO::WorkerBase.
Definition at line 172 of file forwardingworkerbase.cpp.
◆ rename()
|
overridevirtual |
Rename oldname
into newname
.
If the worker returns an error ERR_UNSUPPORTED_ACTION, the job will ask for copy + del instead.
Important: the worker 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 worker 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
-
src where to move the file from dest where to move the file to flags We support Overwrite here
Reimplemented from KIO::WorkerBase.
Definition at line 232 of file forwardingworkerbase.cpp.
◆ requestedUrl()
|
protected |
Return the URL asked to the KIO worker Only access it inside adjustUDSEntry()
Definition at line 155 of file forwardingworkerbase.cpp.
◆ rewriteUrl()
|
protectedpure virtual |
Rewrite an url to its forwarded counterpart.
It should return true if everything was ok, and false otherwise.
If a problem is detected it's up to this method to trigger error() before returning. Returning false silently cancels the current KIO worker operation.
- Parameters
-
url The URL as given during the KIO worker call newURL The new URL to forward the KIO worker call to
- Returns
- true if the given url could be correctly rewritten
◆ setModificationTime()
|
overridevirtual |
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 worker emits ERR_DOES_NOT_EXIST or ERR_CANNOT_SETTIME
Reimplemented from KIO::WorkerBase.
Definition at line 276 of file forwardingworkerbase.cpp.
◆ stat()
|
overridevirtual |
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".
Reimplemented from KIO::WorkerBase.
Definition at line 184 of file forwardingworkerbase.cpp.
◆ symlink()
|
overridevirtual |
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. flags We support Overwrite here
Reimplemented from KIO::WorkerBase.
Definition at line 250 of file forwardingworkerbase.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.