.TH "KIO::ForwardingSlaveBase" kde3 "11 Jun 2005" "Version Version 3.4.1" "kio Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KIO::ForwardingSlaveBase \- This class should be used as a base for ioslaves acting as a forwarder to other ioslaves.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <forwardingslavebase.h>\fP
.PP
Inherits \fBQObject\fP, and \fBKIO::SlaveBase\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBForwardingSlaveBase\fP (const \fBQCString\fP &protocol, const \fBQCString\fP &poolSocket, const \fBQCString\fP &appSocket)"
.br
.ti -1c
.RI "virtual void \fBget\fP (const \fBKURL\fP &url)"
.br
.ti -1c
.RI "virtual void \fBput\fP (const \fBKURL\fP &url, int permissions, bool overwrite, bool resume)"
.br
.ti -1c
.RI "virtual void \fBstat\fP (const \fBKURL\fP &url)"
.br
.ti -1c
.RI "virtual void \fBmimetype\fP (const \fBKURL\fP &url)"
.br
.ti -1c
.RI "virtual void \fBlistDir\fP (const \fBKURL\fP &url)"
.br
.ti -1c
.RI "virtual void \fBmkdir\fP (const \fBKURL\fP &url, int permissions)"
.br
.ti -1c
.RI "virtual void \fBrename\fP (const \fBKURL\fP &src, const \fBKURL\fP &dest, bool overwrite)"
.br
.ti -1c
.RI "virtual void \fBsymlink\fP (const \fBQString\fP &target, const \fBKURL\fP &dest, bool overwrite)"
.br
.ti -1c
.RI "virtual void \fBchmod\fP (const \fBKURL\fP &url, int permissions)"
.br
.ti -1c
.RI "virtual void \fBcopy\fP (const \fBKURL\fP &src, const \fBKURL\fP &dest, int permissions, bool overwrite)"
.br
.ti -1c
.RI "virtual void \fBdel\fP (const \fBKURL\fP &url, bool isfile)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual bool \fBrewriteURL\fP (const \fBKURL\fP &url, \fBKURL\fP &newURL)=0"
.br
.ti -1c
.RI "virtual void \fBprepareUDSEntry\fP (\fBKIO::UDSEntry\fP &entry, bool listing=false) const "
.br
.ti -1c
.RI "\fBKURL\fP \fBprocessedURL\fP () const "
.br
.ti -1c
.RI "\fBKURL\fP \fBrequestedURL\fP () const "
.br
.in -1c
.SH "Detailed Description"
.PP 
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.
.PP
If the resulting ioslave should be a simple proxy, you only need to implement the \fBForwardingSlaveBase::rewriteURL()\fP method.
.PP
For more advanced behavior, the classic ioslave methods should be reimplemented, because their default behavior in this class is to forward using the \fBForwardingSlaveBase::rewriteURL()\fP method.
.PP
A possible code snippet for an advanced \fBstat()\fP behavior would look like this in the child class:
.PP
.PP
.nf
     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);
         }
     }
.fi
.PP
.PP
Of course in this case, you surely need to reimplement \fBlistDir()\fP and \fBget()\fP accordingly.
.PP
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 \fBKDirNotify\fP Files*() DCOP signals.
.PP
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.
.PP
\fBSee also:\fP
.RS 4
\fBForwardingSlaveBase::rewriteURL()\fP 
.RE
.PP
\fBSince:\fP
.RS 4
3.4 
.RE
.PP
\fBAuthor:\fP
.RS 4
Kevin Ottens <ervin@ipsquad.net> 
.RE
.PP

.PP
Definition at line 88 of file forwardingslavebase.h.
.SH "Member Function Documentation"
.PP 
.SS "void KIO::ForwardingSlaveBase::get (const \fBKURL\fP & url)\fC [virtual]\fP"
.PP
get, aka read. 
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP the full url for this request. Host, port and user of the URL can be assumed to be the same as in the last \fBsetHost()\fP call. The slave emits the data through data 
.RE
.PP

.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 172 of file forwardingslavebase.cpp.
.PP
References endl(), KIO::get(), and kdDebug().
.SS "void KIO::ForwardingSlaveBase::put (const \fBKURL\fP & url, int permissions, bool overwrite, bool resume)\fC [virtual]\fP"
.PP
put, aka write. 
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP where to write the file (decoded) 
.br
\fIpermissions\fP may be -1. In this case no special permission mode is set. 
.br
\fIoverwrite\fP if true, any existing file will be overwritten. If the file indeed already exists, the slave should NOT apply the permissions change to it. 
.br
\fIresume\fP 
.RE
.PP

.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 186 of file forwardingslavebase.cpp.
.PP
References endl(), kdDebug(), and KIO::put().
.SS "void KIO::ForwardingSlaveBase::stat (const \fBKURL\fP & url)\fC [virtual]\fP"
.PP
Finds all details for one file or directory. 
.PP
The information returned is the same as what listDir returns, but only for one file or directory. 
.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 202 of file forwardingslavebase.cpp.
.PP
References endl(), kdDebug(), and KIO::stat().
.SS "void KIO::ForwardingSlaveBase::mimetype (const \fBKURL\fP & url)\fC [virtual]\fP"
.PP
Finds mimetype for one file or directory. 
.PP
This method should either emit 'mimeType' or it should send a block of data big enough to be able to determine the mimetype.
.PP
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. 
.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 216 of file forwardingslavebase.cpp.
.PP
References endl(), kdDebug(), and KIO::mimetype().
.PP
Referenced by prepareUDSEntry().
.SS "void KIO::ForwardingSlaveBase::listDir (const \fBKURL\fP & url)\fC [virtual]\fP"
.PP
Lists the contents of \fCurl\fP. 
.PP
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. 
.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 230 of file forwardingslavebase.cpp.
.PP
References endl(), kdDebug(), and KIO::listDir().
.SS "void KIO::ForwardingSlaveBase::mkdir (const \fBKURL\fP & url, int permissions)\fC [virtual]\fP"
.PP
Create a directory. 
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP path to the directory to create 
.br
\fIpermissions\fP the permissions to set after creating the directory (-1 if no permissions to be set) The slave emits ERR_COULD_NOT_MKDIR if failure. 
.RE
.PP

.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 244 of file forwardingslavebase.cpp.
.PP
References endl(), kdDebug(), and KIO::mkdir().
.SS "void KIO::ForwardingSlaveBase::rename (const \fBKURL\fP & src, const \fBKURL\fP & dest, bool overwrite)\fC [virtual]\fP"
.PP
Rename \fColdname\fP into \fCnewname\fP. 
.PP
If the slave returns an error ERR_UNSUPPORTED_ACTION, the job will ask for copy + del instead. 
.PP
\fBParameters:\fP
.RS 4
\fIsrc\fP where to move the file from 
.br
\fIdest\fP where to move the file to 
.br
\fIoverwrite\fP if true, any existing file will be overwritten 
.RE
.PP

.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 258 of file forwardingslavebase.cpp.
.PP
References endl(), kdDebug(), and KIO::rename().
.SS "void KIO::ForwardingSlaveBase::symlink (const \fBQString\fP & target, const \fBKURL\fP & dest, bool overwrite)\fC [virtual]\fP"
.PP
Creates a symbolic link named \fCdest\fP, pointing to \fCtarget\fP, which may be a relative or an absolute path. 
.PP
\fBParameters:\fP
.RS 4
\fItarget\fP The string that will become the 'target' of the link (can be relative) 
.br
\fIdest\fP The symlink to create. 
.br
\fIoverwrite\fP whether to automatically overwrite if the dest exists 
.RE
.PP

.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 273 of file forwardingslavebase.cpp.
.PP
References endl(), kdDebug(), and KIO::symlink().
.SS "void KIO::ForwardingSlaveBase::chmod (const \fBKURL\fP & url, int permissions)\fC [virtual]\fP"
.PP
Change permissions on \fCpath\fP The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD. 
.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 288 of file forwardingslavebase.cpp.
.PP
References KIO::chmod(), endl(), and kdDebug().
.SS "void KIO::ForwardingSlaveBase::copy (const \fBKURL\fP & src, const \fBKURL\fP & dest, int permissions, bool overwrite)\fC [virtual]\fP"
.PP
Copy \fCsrc\fP into \fCdest\fP. 
.PP
If the slave returns an error ERR_UNSUPPORTED_ACTION, the job will ask for get + put instead. 
.PP
\fBParameters:\fP
.RS 4
\fIsrc\fP where to copy the file from (decoded) 
.br
\fIdest\fP where to copy the file to (decoded) 
.br
\fIpermissions\fP may be -1. In this case no special permission mode is set. 
.br
\fIoverwrite\fP if true, any existing file will be overwritten 
.RE
.PP

.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 302 of file forwardingslavebase.cpp.
.PP
References endl(), KIO::file_copy(), and kdDebug().
.SS "void KIO::ForwardingSlaveBase::del (const \fBKURL\fP & url, bool isfile)\fC [virtual]\fP"
.PP
Delete a file or directory. 
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP file/directory to delete 
.br
\fIisfile\fP if true, a file should be deleted. if false, a directory should be deleted. 
.RE
.PP

.PP
Reimplemented from \fBKIO::SlaveBase\fP.
.PP
Definition at line 318 of file forwardingslavebase.cpp.
.PP
References KIO::del(), endl(), kdDebug(), and KIO::rmdir().
.SS "virtual bool KIO::ForwardingSlaveBase::rewriteURL (const \fBKURL\fP & url, \fBKURL\fP & newURL)\fC [protected, pure virtual]\fP"
.PP
Rewrite an url to it's forwarded counterpart. 
.PP
It should return true if everything was ok, and false otherwise.
.PP
If a problem is detected it's up to this method to trigger \fBerror()\fP before returning. Returning false silently cancel the current slave operation.
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP The URL as given during the slave call 
.br
\fInewURL\fP The new URL to forward the slave call to 
.RE
.PP
\fBReturns:\fP
.RS 4
true if the given url could be correctly rewritten 
.RE
.PP

.SS "void KIO::ForwardingSlaveBase::prepareUDSEntry (\fBKIO::UDSEntry\fP & entry, bool listing = \fCfalse\fP) const\fC [protected, virtual]\fP"
.PP
Allow to modify a UDSEntry before it's sent to the ioslave enpoint. 
.PP
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...)
.PP
\fBParameters:\fP
.RS 4
\fIentry\fP the UDSEntry to post-process 
.br
\fIlisting\fP indicate if this entry it created during a listDir operation 
.RE
.PP

.PP
Definition at line 66 of file forwardingslavebase.cpp.
.PP
References KURL::addPath(), QString::append(), endl(), KURL::fileName(), KMimeType::findByURL(), KURL::isLocalFile(), kdDebug(), KIO::mimetype(), mimetype(), KURL::path(), KProtocolInfo::protocolClass(), and KURL::url().
.SS "\fBKURL\fP KIO::ForwardingSlaveBase::processedURL () const\fC [inline, protected]\fP"
.PP
Return the URL being processed by the ioslave Only access it inside \fBprepareUDSEntry()\fP. 
.PP
Definition at line 154 of file forwardingslavebase.h.
.SS "\fBKURL\fP KIO::ForwardingSlaveBase::requestedURL () const\fC [inline, protected]\fP"
.PP
Return the URL asked to the ioslave Only access it inside \fBprepareUDSEntry()\fP. 
.PP
Definition at line 160 of file forwardingslavebase.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for kio Library from the source code.
