KIO::ForwardingSlaveBase

Search for usage in LXR

KIO::ForwardingSlaveBase Class Referenceabstract

#include <KIO/ForwardingSlaveBase>

Inheritance diagram for KIO::ForwardingSlaveBase:

Public Member Functions

 ForwardingSlaveBase (const QByteArray &protocol, const QByteArray &poolSocket, const QByteArray &appSocket)
 
void chmod (const QUrl &url, int permissions) override
 
void copy (const QUrl &src, const QUrl &dest, int permissions, JobFlags flags) override
 
void del (const QUrl &url, bool isfile) override
 
void get (const QUrl &url) override
 
void listDir (const QUrl &url) override
 
void mimetype (const QUrl &url) override
 
void mkdir (const QUrl &url, int permissions) override
 
void put (const QUrl &url, int permissions, JobFlags flags) override
 
void rename (const QUrl &src, const QUrl &dest, JobFlags flags) override
 
void setModificationTime (const QUrl &url, const QDateTime &mtime) override
 
void stat (const QUrl &url) override
 
void symlink (const QString &target, const QUrl &dest, JobFlags flags) override
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () 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 ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, 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
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
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 setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 
- Public Member Functions inherited from KIO::SlaveBase
 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 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 ()
 
void data (const QByteArray &data)
 
void dataReq ()
 
void disconnectSlave ()
 
virtual void dispatch (int command, const QByteArray &data)
 
void dispatchLoop ()
 
virtual void dispatchOpenCommand (int command, const QByteArray &data)
 
void dropNetwork (const QString &host=QString())
 
void error (int _errid, const QString &_text)
 
void errorPage ()
 
void exit ()
 
void finished ()
 
bool hasMetaData (const QString &key) const
 
void infoMessage (const QString &msg)
 
void listEntries (const UDSEntryList &_entry)
 
void listEntry (const UDSEntry &_entry, bool ready)
 
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 multiGet (const QByteArray &data)
 
void needSubUrlData ()
 
virtual void open (const QUrl &url, QIODevice::OpenMode mode)
 
virtual void openConnection ()
 
void opened ()
 
bool openPasswordDialog (KIO::AuthInfo &info, const QString &errorMsg=QString())
 
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 read (KIO::filesize_t size)
 
int readData (QByteArray &buffer)
 
int readTimeout ()
 
void redirection (const QUrl &_url)
 
KRemoteEncodingremoteEncoding ()
 
virtual void reparseConfiguration ()
 
bool requestNetwork (const QString &host=QString())
 
PrivilegeOperationStatus requestPrivilegeOperation ()
 
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 setSubUrl (const QUrl &url)
 
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)
 
void statEntry (const UDSEntry &_entry)
 
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 Member Functions

virtual void prepareUDSEntry (KIO::UDSEntry &entry, bool listing=false) 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
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Member Functions inherited from KIO::SlaveBase
virtual void virtual_hook (int id, void *data)
 

Additional Inherited Members

- Public Types inherited from KIO::SlaveBase
enum  ButtonCode {
  Ok = 1, Cancel = 2, PrimaryAction = 3, SecondaryAction = 4,
  Continue = 5, Yes = PrimaryAction, No = SecondaryAction
}
 
enum  MessageBoxType {
  QuestionTwoActions = 1, WarningTwoActions = 2, WarningContinueCancel = 3, WarningTwoActionsCancel = 4,
  Information = 5, SSLMessageBox = 6, WarningContinueCancelDetailed = 10, QuestionYesNo = QuestionTwoActions,
  WarningYesNo = WarningTwoActions, WarningYesNoCancel = WarningTwoActionsCancel
}
 
- 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)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Types inherited from KIO::SlaveBase
enum  VirtualFunctionId { AppConnectionMade = 0, GetFileSystemFreeSpace = 1, Truncate = 2 }
 
- Protected Attributes inherited from KIO::SlaveBase
MetaData mIncomingMetaData
 
MetaData mOutgoingMetaData
 
QByteArray mProtocol
 

Detailed Description

This class should be used as a base for ioslaves acting as a forwarder to other ioslaves. It has been designed to support only local filesystem like ioslaves.

If the resulting ioslave should be a simple proxy, you only need to implement the ForwardingSlaveBase::rewriteUrl() method.

For more advanced behavior, the classic ioslave methods should be reimplemented, because their default behavior in this class is to forward using the ForwardingSlaveBase::rewriteUrl() method.

A possible code snippet for an advanced stat() behavior would look like this in the child class:

void ChildProtocol::stat(const QUrl &url)
{
bool is_special = false;
// Process the URL to see if it should have
// a special treatment
if ( is_special )
{
// Handle the URL ourselves
// Fill entry with UDSAtom instances
statEntry(entry);
}
else
{
// Setup the ioslave internal state if
// required by ChildProtocol::rewriteUrl()
}
}

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.

This class was initially used for media:/ ioslave. This ioslave code and the MediaDirNotify class of its companion kded module can be a good source of inspiration.

See also
ForwardingSlaveBase::rewriteUrl()
Author
Kevin Ottens ervin.nosp@m.@ips.nosp@m.quad..nosp@m.net
Deprecated:
Since 5.101, use ForwardingWorkerBase.

Definition at line 84 of file forwardingslavebase.h.

Member Function Documentation

◆ chmod()

void KIO::ForwardingSlaveBase::chmod ( const QUrl url,
int  permissions 
)
overridevirtual

Change permissions on url.

The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD

Reimplemented from KIO::SlaveBase.

Definition at line 255 of file forwardingslavebase.cpp.

◆ copy()

void KIO::ForwardingSlaveBase::copy ( const QUrl src,
const QUrl dest,
int  permissions,
JobFlags  flags 
)
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 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.

Reimplemented from KIO::SlaveBase.

Definition at line 281 of file forwardingslavebase.cpp.

◆ del()

void KIO::ForwardingSlaveBase::del ( const QUrl url,
bool  isfile 
)
overridevirtual

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.

Reimplemented from KIO::SlaveBase.

Definition at line 299 of file forwardingslavebase.cpp.

◆ get()

void KIO::ForwardingSlaveBase::get ( const QUrl url)
overridevirtual

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

Reimplemented from KIO::SlaveBase.

Definition at line 144 of file forwardingslavebase.cpp.

◆ listDir()

void KIO::ForwardingSlaveBase::listDir ( const QUrl url)
overridevirtual

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.

Reimplemented from KIO::SlaveBase.

Definition at line 196 of file forwardingslavebase.cpp.

◆ mimetype()

void KIO::ForwardingSlaveBase::mimetype ( const QUrl url)
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 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.

Reimplemented from KIO::SlaveBase.

Definition at line 183 of file forwardingslavebase.cpp.

◆ mkdir()

void KIO::ForwardingSlaveBase::mkdir ( const QUrl url,
int  permissions 
)
overridevirtual

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.

Reimplemented from KIO::SlaveBase.

Definition at line 209 of file forwardingslavebase.cpp.

◆ prepareUDSEntry()

void KIO::ForwardingSlaveBase::prepareUDSEntry ( KIO::UDSEntry entry,
bool  listing = false 
) const
protectedvirtual

Allow to modify a UDSEntry before it's sent to the ioslave 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
entrythe UDSEntry to post-process
listingindicate if this entry it created during a listDir operation

Definition at line 87 of file forwardingslavebase.cpp.

◆ processedUrl()

QUrl KIO::ForwardingSlaveBase::processedUrl ( ) const
protected

Return the URL being processed by the ioslave Only access it inside prepareUDSEntry()

Definition at line 134 of file forwardingslavebase.cpp.

◆ put()

void KIO::ForwardingSlaveBase::put ( const QUrl url,
int  permissions,
JobFlags  flags 
)
overridevirtual

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

Reimplemented from KIO::SlaveBase.

Definition at line 157 of file forwardingslavebase.cpp.

◆ rename()

void KIO::ForwardingSlaveBase::rename ( const QUrl src,
const QUrl dest,
JobFlags  flags 
)
overridevirtual

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

Reimplemented from KIO::SlaveBase.

Definition at line 222 of file forwardingslavebase.cpp.

◆ requestedUrl()

QUrl KIO::ForwardingSlaveBase::requestedUrl ( ) const
protected

Return the URL asked to the ioslave Only access it inside prepareUDSEntry()

Definition at line 139 of file forwardingslavebase.cpp.

◆ rewriteUrl()

virtual bool KIO::ForwardingSlaveBase::rewriteUrl ( const QUrl url,
QUrl newURL 
)
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 slave operation.

Parameters
urlThe URL as given during the slave call
newURLThe new URL to forward the slave call to
Returns
true if the given url could be correctly rewritten

◆ setModificationTime()

void KIO::ForwardingSlaveBase::setModificationTime ( const QUrl url,
const QDateTime mtime 
)
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 slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_SETTIME

Reimplemented from KIO::SlaveBase.

Definition at line 268 of file forwardingslavebase.cpp.

◆ stat()

void KIO::ForwardingSlaveBase::stat ( const QUrl url)
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::SlaveBase.

Definition at line 170 of file forwardingslavebase.cpp.

◆ symlink()

void KIO::ForwardingSlaveBase::symlink ( const QString target,
const QUrl dest,
JobFlags  flags 
)
overridevirtual

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

Reimplemented from KIO::SlaveBase.

Definition at line 240 of file forwardingslavebase.cpp.


The documentation for this class was generated from the following files:
void stat(const QUrl &url) override
Finds all details for one file or directory.
void finished()
Call to signal successful completion of any command besides openConnection and closeConnection.
Definition: slavebase.cpp:551
void statEntry(const UDSEntry &_entry)
Call this from stat() to express details about an object, the UDSEntry customarily contains the atoms...
Definition: slavebase.cpp:798
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 8 2023 03:51:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.