KIO::ForwardingSlaveBase Class Reference
This class should be used as a base for ioslaves acting as a forwarder to other ioslaves. More...
#include <forwardingslavebase.h>
Inheritance diagram for KIO::ForwardingSlaveBase:

Public Member Functions | |
ForwardingSlaveBase (const QCString &protocol, const QCString &poolSocket, const QCString &appSocket) | |
virtual void | get (const KURL &url) |
virtual void | put (const KURL &url, int permissions, bool overwrite, bool resume) |
virtual void | stat (const KURL &url) |
virtual void | mimetype (const KURL &url) |
virtual void | listDir (const KURL &url) |
virtual void | mkdir (const KURL &url, int permissions) |
virtual void | rename (const KURL &src, const KURL &dest, bool overwrite) |
virtual void | symlink (const QString &target, const KURL &dest, bool overwrite) |
virtual void | chmod (const KURL &url, int permissions) |
virtual void | copy (const KURL &src, const KURL &dest, int permissions, bool overwrite) |
virtual void | del (const KURL &url, bool isfile) |
Protected Member Functions | |
virtual bool | rewriteURL (const KURL &url, KURL &newURL)=0 |
virtual void | prepareUDSEntry (KIO::UDSEntry &entry, bool listing=false) const |
KURL | processedURL () const |
KURL | requestedURL () const |
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 KURL &url) { bool is_special = false; // Process the URL to see if it should have // a special treatment if ( is_special ) { // Handle the URL ourselves KIO::UDSEntry entry; // Fill entry with UDSAtom instances statEntry(entry); finished(); } else { // Setup the ioslave internal state if // required by ChildProtocol::rewriteURL() ForwardingSlaveBase::stat(url); } }
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*() DCOP 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()
- Since:
- 3.4
- Author:
- Kevin Ottens <ervin@ipsquad.net>
Definition at line 88 of file forwardingslavebase.h.
Member Function Documentation
|
get, aka read.
Reimplemented from KIO::SlaveBase. Definition at line 172 of file forwardingslavebase.cpp. References endl(), KIO::get(), and kdDebug(). |
|
put, aka write.
Reimplemented from KIO::SlaveBase. Definition at line 186 of file forwardingslavebase.cpp. References endl(), kdDebug(), and KIO::put(). |
|
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. Reimplemented from KIO::SlaveBase. Definition at line 202 of file forwardingslavebase.cpp. References endl(), kdDebug(), and KIO::stat(). |
|
Finds mimetype for one file or directory. This method should either emit 'mimeType' or it should send a block of data big enough to be able to determine the mimetype. If the slave doesn't reimplement it, a get will be issued, i.e. the whole file will be downloaded before determining the mimetype on it - this is obviously not a good thing in most cases. Reimplemented from KIO::SlaveBase. Definition at line 216 of file forwardingslavebase.cpp. References endl(), kdDebug(), and KIO::mimetype(). Referenced by prepareUDSEntry(). |
|
Lists the contents of The slave should emit ERR_CANNOT_ENTER_DIRECTORY if it doesn't exist, if we don't have enough permissions, or if it is a file It should also emit totalFiles as soon as it knows how many files it will list. Reimplemented from KIO::SlaveBase. Definition at line 230 of file forwardingslavebase.cpp. References endl(), kdDebug(), and KIO::listDir(). |
|
Create a directory.
Reimplemented from KIO::SlaveBase. Definition at line 244 of file forwardingslavebase.cpp. References endl(), kdDebug(), and KIO::mkdir(). |
|
Rename If the slave returns an error ERR_UNSUPPORTED_ACTION, the job will ask for copy + del instead.
Reimplemented from KIO::SlaveBase. Definition at line 258 of file forwardingslavebase.cpp. References endl(), kdDebug(), and KIO::rename(). |
|
Creates a symbolic link named
Reimplemented from KIO::SlaveBase. Definition at line 273 of file forwardingslavebase.cpp. References endl(), kdDebug(), and KIO::symlink(). |
|
Change permissions on
Reimplemented from KIO::SlaveBase. Definition at line 288 of file forwardingslavebase.cpp. References KIO::chmod(), endl(), and kdDebug(). |
|
Copy If the slave returns an error ERR_UNSUPPORTED_ACTION, the job will ask for get + put instead.
Reimplemented from KIO::SlaveBase. Definition at line 302 of file forwardingslavebase.cpp. References endl(), KIO::file_copy(), and kdDebug(). |
|
Delete a file or directory.
Reimplemented from KIO::SlaveBase. Definition at line 318 of file forwardingslavebase.cpp. References KIO::del(), endl(), kdDebug(), and KIO::rmdir(). |
|
Rewrite an url to it's 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 cancel the current slave operation.
|
|
Allow to modify a UDSEntry before it's sent to the ioslave enpoint. This is the default implementation working in most case, but sometimes you could make use of more forwarding black magic (for example dynamically transform any desktop file into a fake directory...)
Definition at line 66 of file forwardingslavebase.cpp. References KURL::addPath(), endl(), KURL::fileName(), KMimeType::findByURL(), KURL::isLocalFile(), kdDebug(), mimetype(), KIO::SlaveBase::mProtocol, KURL::path(), KProtocolInfo::protocolClass(), KIO::UDS_LOCAL_PATH, KIO::UDS_MIME_TYPE, KIO::UDS_NAME, KIO::UDS_URL, and KURL::url(). |
|
Return the URL being processed by the ioslave Only access it inside prepareUDSEntry().
Definition at line 154 of file forwardingslavebase.h. |
|
Return the URL asked to the ioslave Only access it inside prepareUDSEntry().
Definition at line 160 of file forwardingslavebase.h. |
The documentation for this class was generated from the following files: