\section{KIO::Forwarding\-Slave\-Base Class Reference}
\label{classKIO_1_1ForwardingSlaveBase}\index{KIO::ForwardingSlaveBase@{KIO::ForwardingSlaveBase}}
This class should be used as a base for ioslaves acting as a forwarder to other ioslaves.  


{\tt \#include $<$forwardingslavebase.h$>$}

Inheritance diagram for KIO::Forwarding\-Slave\-Base:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=96pt]{classKIO_1_1ForwardingSlaveBase__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KIO::Forwarding\-Slave\-Base:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=306pt]{classKIO_1_1ForwardingSlaveBase__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Forwarding\-Slave\-Base} (const {\bf QCString} \&protocol, const {\bf QCString} \&pool\-Socket, const {\bf QCString} \&app\-Socket)\label{classKIO_1_1ForwardingSlaveBase_a0}

\item 
virtual void {\bf get} (const {\bf KURL} \&url)
\item 
virtual void {\bf put} (const {\bf KURL} \&url, int permissions, bool overwrite, bool resume)
\item 
virtual void {\bf stat} (const {\bf KURL} \&url)
\item 
virtual void {\bf mimetype} (const {\bf KURL} \&url)
\item 
virtual void {\bf list\-Dir} (const {\bf KURL} \&url)
\item 
virtual void {\bf mkdir} (const {\bf KURL} \&url, int permissions)
\item 
virtual void {\bf rename} (const {\bf KURL} \&src, const {\bf KURL} \&dest, bool overwrite)
\item 
virtual void {\bf symlink} (const {\bf QString} \&target, const {\bf KURL} \&dest, bool overwrite)
\item 
virtual void {\bf chmod} (const {\bf KURL} \&url, int permissions)
\item 
virtual void {\bf copy} (const {\bf KURL} \&src, const {\bf KURL} \&dest, int permissions, bool overwrite)
\item 
virtual void {\bf del} (const {\bf KURL} \&url, bool isfile)
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual bool {\bf rewrite\-URL} (const {\bf KURL} \&url, {\bf KURL} \&new\-URL)=0
\item 
virtual void {\bf prepare\-UDSEntry} ({\bf KIO::UDSEntry} \&entry, bool listing=false) const 
\item 
{\bf KURL} {\bf processed\-URL} () const 
\item 
{\bf KURL} {\bf requested\-URL} () const 
\end{CompactItemize}


\subsection{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 {\bf Forwarding\-Slave\-Base::rewrite\-URL()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_b0})} method.

For more advanced behavior, the classic ioslave methods should be reimplemented, because their default behavior in this class is to forward using the {\bf Forwarding\-Slave\-Base::rewrite\-URL()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_b0})} method.

A possible code snippet for an advanced {\bf stat()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_a4})} behavior would look like this in the child class:



\footnotesize\begin{verbatim}     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);
         }
     }
\end{verbatim}
\normalsize


Of course in this case, you surely need to reimplement {\bf list\-Dir()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_a6})} and {\bf get()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_a2})} 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 {\bf KDir\-Notify}{\rm (p.\,\pageref{classKDirNotify})} Files$\ast$() DCOP signals.

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

\begin{Desc}
\item[See also:]{\bf Forwarding\-Slave\-Base::rewrite\-URL()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_b0})} \end{Desc}
\begin{Desc}
\item[Since:]3.4 \end{Desc}
\begin{Desc}
\item[Author:]Kevin Ottens $<${\tt ervin@ipsquad.net}$>$ \end{Desc}




Definition at line 88 of file forwardingslavebase.h.

\subsection{Member Function Documentation}
\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!get@{get}}
\index{get@{get}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::get (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a2}


get, aka read. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em 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 {\bf set\-Host()}{\rm (p.\,\pageref{classKIO_1_1SlaveBase_a35})} call. The slave emits the data through data \end{description}
\end{Desc}


Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a39})}.

Definition at line 172 of file forwardingslavebase.cpp.

References endl(), KIO::get(), and kd\-Debug().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!put@{put}}
\index{put@{put}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::put (const {\bf KURL} \& {\em url}, int {\em permissions}, bool {\em overwrite}, bool {\em resume})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a3}


put, aka write. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]where to write the file (decoded) \item[{\em permissions}]may be -1. In this case no special permission mode is set. \item[{\em overwrite}]if true, any existing file will be overwritten. If the file indeed already exists, the slave should NOT apply the permissions change to it. \item[{\em resume}]\end{description}
\end{Desc}


Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a40})}.

Definition at line 186 of file forwardingslavebase.cpp.

References endl(), kd\-Debug(), and KIO::put().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!stat@{stat}}
\index{stat@{stat}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::stat (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a4}


Finds all details for one file or directory. 

The information returned is the same as what list\-Dir returns, but only for one file or directory. 

Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a41})}.

Definition at line 202 of file forwardingslavebase.cpp.

References endl(), kd\-Debug(), and KIO::stat().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!mimetype@{mimetype}}
\index{mimetype@{mimetype}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::mimetype (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a5}


Finds mimetype for one file or directory. 

This method should either emit 'mime\-Type' 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 {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a42})}.

Definition at line 216 of file forwardingslavebase.cpp.

References endl(), kd\-Debug(), and KIO::mimetype().

Referenced by prepare\-UDSEntry().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!listDir@{listDir}}
\index{listDir@{listDir}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::list\-Dir (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a6}


Lists the contents of {\tt url}. 

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 total\-Files as soon as it knows how many files it will list. 

Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a43})}.

Definition at line 230 of file forwardingslavebase.cpp.

References endl(), kd\-Debug(), and KIO::list\-Dir().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!mkdir@{mkdir}}
\index{mkdir@{mkdir}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::mkdir (const {\bf KURL} \& {\em url}, int {\em permissions})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a7}


Create a directory. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]path to the directory to create \item[{\em permissions}]the permissions to set after creating the directory (-1 if no permissions to be set) The slave emits ERR\_\-COULD\_\-NOT\_\-MKDIR if failure. \end{description}
\end{Desc}


Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a44})}.

Definition at line 244 of file forwardingslavebase.cpp.

References endl(), kd\-Debug(), and KIO::mkdir().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!rename@{rename}}
\index{rename@{rename}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::rename (const {\bf KURL} \& {\em src}, const {\bf KURL} \& {\em dest}, bool {\em overwrite})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a8}


Rename {\tt oldname} into {\tt newname}. 

If the slave returns an error ERR\_\-UNSUPPORTED\_\-ACTION, the job will ask for copy + del instead. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em src}]where to move the file from \item[{\em dest}]where to move the file to \item[{\em overwrite}]if true, any existing file will be overwritten \end{description}
\end{Desc}


Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a45})}.

Definition at line 258 of file forwardingslavebase.cpp.

References endl(), kd\-Debug(), and KIO::rename().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!symlink@{symlink}}
\index{symlink@{symlink}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::symlink (const {\bf QString} \& {\em target}, const {\bf KURL} \& {\em dest}, bool {\em overwrite})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a9}


Creates a symbolic link named {\tt dest}, pointing to {\tt target}, which may be a relative or an absolute path. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em target}]The string that will become the \char`\"{}target\char`\"{} of the link (can be relative) \item[{\em dest}]The symlink to create. \item[{\em overwrite}]whether to automatically overwrite if the dest exists \end{description}
\end{Desc}


Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a46})}.

Definition at line 273 of file forwardingslavebase.cpp.

References endl(), kd\-Debug(), and KIO::symlink().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!chmod@{chmod}}
\index{chmod@{chmod}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::chmod (const {\bf KURL} \& {\em url}, int {\em permissions})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a10}


Change permissions on {\tt path} The slave emits ERR\_\-DOES\_\-NOT\_\-EXIST or ERR\_\-CANNOT\_\-CHMOD. 



Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a47})}.

Definition at line 288 of file forwardingslavebase.cpp.

References KIO::chmod(), endl(), and kd\-Debug().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!copy@{copy}}
\index{copy@{copy}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::copy (const {\bf KURL} \& {\em src}, const {\bf KURL} \& {\em dest}, int {\em permissions}, bool {\em overwrite})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a11}


Copy {\tt src} into {\tt dest}. 

If the slave returns an error ERR\_\-UNSUPPORTED\_\-ACTION, the job will ask for get + put instead. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em src}]where to copy the file from (decoded) \item[{\em dest}]where to copy the file to (decoded) \item[{\em permissions}]may be -1. In this case no special permission mode is set. \item[{\em overwrite}]if true, any existing file will be overwritten \end{description}
\end{Desc}


Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a48})}.

Definition at line 302 of file forwardingslavebase.cpp.

References endl(), KIO::file\_\-copy(), and kd\-Debug().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!del@{del}}
\index{del@{del}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::del (const {\bf KURL} \& {\em url}, bool {\em isfile})\hspace{0.3cm}{\tt  [virtual]}}\label{classKIO_1_1ForwardingSlaveBase_a12}


Delete a file or directory. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]file/directory to delete \item[{\em isfile}]if true, a file should be deleted. if false, a directory should be deleted. \end{description}
\end{Desc}


Reimplemented from {\bf KIO::Slave\-Base} {\rm (p.\,\pageref{classKIO_1_1SlaveBase_a49})}.

Definition at line 318 of file forwardingslavebase.cpp.

References KIO::del(), endl(), kd\-Debug(), and KIO::rmdir().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!rewriteURL@{rewriteURL}}
\index{rewriteURL@{rewriteURL}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool KIO::Forwarding\-Slave\-Base::rewrite\-URL (const {\bf KURL} \& {\em url}, {\bf KURL} \& {\em new\-URL})\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classKIO_1_1ForwardingSlaveBase_b0}


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 {\bf error()}{\rm (p.\,\pageref{classKIO_1_1SlaveBase_a8})} before returning. Returning false silently cancel the current slave operation.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]The URL as given during the slave call \item[{\em new\-URL}]The new URL to forward the slave call to \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if the given url could be correctly rewritten \end{Desc}
\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!prepareUDSEntry@{prepareUDSEntry}}
\index{prepareUDSEntry@{prepareUDSEntry}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KIO::Forwarding\-Slave\-Base::prepare\-UDSEntry ({\bf KIO::UDSEntry} \& {\em entry}, bool {\em listing} = {\tt false}) const\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKIO_1_1ForwardingSlaveBase_b1}


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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em entry}]the UDSEntry to post-process \item[{\em listing}]indicate if this entry it created during a list\-Dir operation \end{description}
\end{Desc}


Definition at line 66 of file forwardingslavebase.cpp.

References KURL::add\-Path(), QString::append(), endl(), KURL::file\-Name(), KMime\-Type::find\-By\-URL(), KURL::is\-Local\-File(), kd\-Debug(), KIO::mimetype(), mimetype(), KURL::path(), KProtocol\-Info::protocol\-Class(), and KURL::url().\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!processedURL@{processedURL}}
\index{processedURL@{processedURL}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KURL} KIO::Forwarding\-Slave\-Base::processed\-URL () const\hspace{0.3cm}{\tt  [inline, protected]}}\label{classKIO_1_1ForwardingSlaveBase_b2}


Return the URL being processed by the ioslave Only access it inside {\bf prepare\-UDSEntry()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_b1})}. 



Definition at line 154 of file forwardingslavebase.h.\index{KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}!requestedURL@{requestedURL}}
\index{requestedURL@{requestedURL}!KIO::ForwardingSlaveBase@{KIO::Forwarding\-Slave\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KURL} KIO::Forwarding\-Slave\-Base::requested\-URL () const\hspace{0.3cm}{\tt  [inline, protected]}}\label{classKIO_1_1ForwardingSlaveBase_b3}


Return the URL asked to the ioslave Only access it inside {\bf prepare\-UDSEntry()}{\rm (p.\,\pageref{classKIO_1_1ForwardingSlaveBase_b1})}. 



Definition at line 160 of file forwardingslavebase.h.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
forwardingslavebase.h\item 
forwardingslavebase.cpp\end{CompactItemize}
