\section{KIO::Net\-Access Class Reference}
\label{classKIO_1_1NetAccess}\index{KIO::NetAccess@{KIO::NetAccess}}
Net Transparency, formerly provided by kfmlib, but now done with {\bf KIO::Job}{\rm (p.\,\pageref{classKIO_1_1Job})}. Provides a synchronous interface to io jobs.  


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

Inheritance diagram for KIO::Net\-Access:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=61pt]{classKIO_1_1NetAccess__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KIO::Net\-Access:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=190pt]{classKIO_1_1NetAccess__coll__graph}
\end{center}
\end{figure}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
bool {\bf download} (const  {\bf KURL} \&src, {\bf QString} \&target)
\begin{CompactList}\small\item\em Downloads a file from an arbitrary URL ({\tt src}) to a temporary file on the local filesystem ({\tt target}). \item\end{CompactList}\item 
void {\bf remove\-Temp\-File} (const  {\bf QString} \&{\bf name})
\begin{CompactList}\small\item\em Removes the specified file if and only if it was created by KIO::Net\-Access as a temporary file for a former download. \item\end{CompactList}\item 
bool {\bf upload} (const  {\bf QString} \&src, const  {\bf KURL} \&target)
\begin{CompactList}\small\item\em Uploads file {\tt src} to URL {\tt target}. \item\end{CompactList}\item 
bool {\bf copy} (const  {\bf KURL} \&src, const  {\bf KURL} \&target)
\begin{CompactList}\small\item\em Alternative method for copying over the network. \item\end{CompactList}\item 
bool {\bf dircopy} (const  {\bf KURL} \&src, const  {\bf KURL} \&target)
\begin{CompactList}\small\item\em Alternative method for copying over the network. \item\end{CompactList}\item 
bool {\bf exists} (const  {\bf KURL} \&url)
\begin{CompactList}\small\item\em Tests whether a URL exists. \item\end{CompactList}\item 
bool {\bf exists} (const  {\bf KURL} \&url, bool source)
\begin{CompactList}\small\item\em Overloaded version of exists A {\bf stat()}{\rm (p.\,\pageref{classKIO_1_1NetAccess_e7})} can have two meanings. \item\end{CompactList}\item 
bool {\bf stat} (const  {\bf KURL} \&url, {\bf KIO::UDSEntry} \&entry)
\begin{CompactList}\small\item\em Tests whether a URL exists and return information on it. \item\end{CompactList}\item 
bool {\bf del} (const  {\bf KURL} \&url)
\begin{CompactList}\small\item\em Deletes a file or a directory in an synchronous way. \item\end{CompactList}\item 
bool {\bf mkdir} (const  {\bf KURL} \&url, int permissions=-1)
\begin{CompactList}\small\item\em Creates a directory in a synchronous way. \item\end{CompactList}\item 
{\bf QString} {\bf mimetype} (const  {\bf KURL} \&url)
\begin{CompactList}\small\item\em Determines the mimetype of a given URL. \item\end{CompactList}\item 
{\bf QString} {\bf last\-Error\-String} ()
\begin{CompactList}\small\item\em Returns the error string for the last job, in case it failed. \item\end{CompactList}\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf I\_\-like\_\-this\_\-class}\label{classKIO_1_1NetAccess_n0}

\end{CompactItemize}


\subsection{Detailed Description}
Net Transparency, formerly provided by kfmlib, but now done with {\bf KIO::Job}{\rm (p.\,\pageref{classKIO_1_1Job})}. Provides a synchronous interface to io jobs. 

This class isn't meant to be used as a class but only as a simple namespace for static functions, though an instance of the class is built for internal purposes. Whereas a {\bf KIO::Job}{\rm (p.\,\pageref{classKIO_1_1Job})} is asynchronous, meaning that the developer has to connect slots for it, KIO::Net\-Access provides synchronous downloads and uploads, as well as temporary file creation and removal.

Port to kio done by David Faure, {\tt faure@kde.org}



Definition at line 52 of file netaccess.h.

\subsection{Member Function Documentation}
\index{KIO::NetAccess@{KIO::Net\-Access}!download@{download}}
\index{download@{download}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::download (const {\bf KURL} \& {\em src}, {\bf QString} \& {\em target})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e0}


Downloads a file from an arbitrary URL ({\tt src}) to a temporary file on the local filesystem ({\tt target}). 

If the argument for {\tt target} is an empty string, download will generate a unique temporary filename in /tmp. Since {\tt target} is a reference to {\bf QString} you can access this filename easily. Download will return true if the download was successful, otherwise false.

Special case: If the URL is of kind file:, then no downloading is processed but the full filename is returned in {\tt target}. That means you {\em have\/} to take care about the {\tt target} argument. (This is very easy to do, please see the example below.)

Download is synchronous. That means you can use it like this, (assuming {\tt u} is a string which represents a URL and your application has a load\-File() function):

\small\begin{alltt}
 {\bf QString} tmpFile;
 if( KIO::NetAccess::download( u, tmpFile ) )
 \{
   loadFile( tmpFile );
   KIO::NetAccess::removeTempFile( tmpFile );
   \}
 \end{alltt}\normalsize 


Of course, your user interface will still process exposure/repaint events during the download.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em src}]URL Reference to the file to download.\item[{\em target}]String containing the final local location of the file. If you insert an empty string, it will return a location in a temporary spot. \end{description}
\end{Desc}


Definition at line 47 of file netaccess.cpp.

References QString::arg(), copy\-Internal(), QString::is\-Empty(), KURL::is\-Local\-File(), KTemp\-File::name(), KURL::path(), and KURL::set\-Path().\index{KIO::NetAccess@{KIO::Net\-Access}!removeTempFile@{removeTempFile}}
\index{removeTempFile@{removeTempFile}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Net\-Access::remove\-Temp\-File (const {\bf QString} \& {\em name})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e1}


Removes the specified file if and only if it was created by KIO::Net\-Access as a temporary file for a former download. 

Note: This means that if you created your temporary with {\bf KTemp\-File}, use {\bf KTemp\-File::unlink}() or {\bf KTemp\-File::set\-Auto\-Delete}() to have it removed.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]Path to temporary file to remove. May not be empty. \end{description}
\end{Desc}


Definition at line 151 of file netaccess.cpp.

References QFile::encode\-Name(), and KStd\-Accel::name().\index{KIO::NetAccess@{KIO::Net\-Access}!upload@{upload}}
\index{upload@{upload}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::upload (const {\bf QString} \& {\em src}, const {\bf KURL} \& {\em target})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e2}


Uploads file {\tt src} to URL {\tt target}. 

Both must be specified, unlike {\bf download}{\rm (p.\,\pageref{classKIO_1_1NetAccess_e0})}. Note that this is assumed to be used for saving a file over the network, so overwriting is set to true. This is not the case with {\bf copy}{\rm (p.\,\pageref{classKIO_1_1NetAccess_e3})}.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em src}]URL Referencing the file to upload.\item[{\em target}]URL containing the final location of the file. \end{description}
\end{Desc}


Definition at line 77 of file netaccess.cpp.

References copy\-Internal(), KURL::is\-Empty(), KURL::is\-Local\-File(), KURL::path(), and KURL::set\-Path().\index{KIO::NetAccess@{KIO::Net\-Access}!copy@{copy}}
\index{copy@{copy}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::copy (const {\bf KURL} \& {\em src}, const {\bf KURL} \& {\em target})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e3}


Alternative method for copying over the network. 

Overwrite is false, so this will fail if {\tt target} exists.

This one takes two URLs and is a direct equivalent of {\bf KIO::file\_\-copy}{\rm (p.\,\pageref{namespaceKIO_a210})} (not {\bf KIO::copy}{\rm (p.\,\pageref{namespaceKIO_a215})}!). 

Definition at line 94 of file netaccess.cpp.

References copy\-Internal().\index{KIO::NetAccess@{KIO::Net\-Access}!dircopy@{dircopy}}
\index{dircopy@{dircopy}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::dircopy (const {\bf KURL} \& {\em src}, const {\bf KURL} \& {\em target})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e4}


Alternative method for copying over the network. 

Overwrite is false, so this will fail if {\tt target} exists.

This one takes two URLs and is a direct equivalent of {\bf KIO::copy}{\rm (p.\,\pageref{namespaceKIO_a215})}!. 

Definition at line 100 of file netaccess.cpp.

References dircopy\-Internal().\index{KIO::NetAccess@{KIO::Net\-Access}!exists@{exists}}
\index{exists@{exists}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::exists (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e5}


Tests whether a URL exists. 

This is a convenience function for {\bf KIO::stat}{\rm (p.\,\pageref{namespaceKIO_a203})} (it saves creating a slot and testing for the job result).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]the url we are testing \end{description}
\end{Desc}


Definition at line 106 of file netaccess.cpp.

References QFile::exists(), KURL::is\-Local\-File(), KURL::path(), and stat\-Internal().\index{KIO::NetAccess@{KIO::Net\-Access}!exists@{exists}}
\index{exists@{exists}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::exists (const {\bf KURL} \& {\em url}, bool {\em source})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e6}


Overloaded version of exists A {\bf stat()}{\rm (p.\,\pageref{classKIO_1_1NetAccess_e7})} can have two meanings. 

Either we want to read from this URL, or to check if we can write to it. First case is \char`\"{}source\char`\"{}, second is \char`\"{}dest\char`\"{}. It is necessary to know what the Stat\-Job is for, to tune the kioslave's behaviour (e.g. with FTP) Tests whether a URL exists.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]the url we are testing \item[{\em source}]if true, we want to read from that URL. If false, we want to write to it. \end{description}
\end{Desc}


Definition at line 114 of file netaccess.cpp.

References QFile::exists(), KURL::is\-Local\-File(), KURL::path(), and stat\-Internal().\index{KIO::NetAccess@{KIO::Net\-Access}!stat@{stat}}
\index{stat@{stat}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::stat (const {\bf KURL} \& {\em url}, {\bf KIO::UDSEntry} \& {\em entry})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e7}


Tests whether a URL exists and return information on it. 

This is a convenience function for {\bf KIO::stat}{\rm (p.\,\pageref{namespaceKIO_a203})} (it saves creating a slot and testing for the job result).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]The URL we are testing. \item[{\em entry}]The result of the stat. Iterate over the list of atoms to get hold of name, type, size, etc., or use {\bf KFile\-Item}{\rm (p.\,\pageref{classKFileItem})}. \end{description}
\end{Desc}


Definition at line 122 of file netaccess.cpp.

References m\_\-entry, stat\-Internal(), and KIO::UDSEntry.\index{KIO::NetAccess@{KIO::Net\-Access}!del@{del}}
\index{del@{del}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::del (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e8}


Deletes a file or a directory in an synchronous way. 

This is a convenience function for {\bf KIO::del}{\rm (p.\,\pageref{namespaceKIO_a224})} (it saves creating a slot and testing for the job result).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]The file or directory to delete. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]{\tt true} on success, {\tt false} on failure. \end{Desc}


Definition at line 131 of file netaccess.cpp.

References del\-Internal().\index{KIO::NetAccess@{KIO::Net\-Access}!mkdir@{mkdir}}
\index{mkdir@{mkdir}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Net\-Access::mkdir (const {\bf KURL} \& {\em url}, int {\em permissions} = -1)\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e9}


Creates a directory in a synchronous way. 

This is a convenience function for {\tt {\bf KIO::mkdir}{\rm (p.\,\pageref{namespaceKIO_a194})}} (it saves creating a slot and testing for the job result).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]The directory to create. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]{\tt true} on success, {\tt false} on failure. \end{Desc}


Definition at line 137 of file netaccess.cpp.

References mkdir\-Internal().

Referenced by KDir\-Operator::mkdir().\index{KIO::NetAccess@{KIO::Net\-Access}!mimetype@{mimetype}}
\index{mimetype@{mimetype}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} Net\-Access::mimetype (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [static]}}\label{classKIO_1_1NetAccess_e10}


Determines the mimetype of a given URL. 

This is a convenience function for {\bf KIO::mimetype}{\rm (p.\,\pageref{namespaceKIO_a209})}. You should call this only when really necessary. {\bf KMime\-Type::find\-By\-URL}{\rm (p.\,\pageref{classKMimeType_e4})} can determine extension a lot faster, but less reliably for remote files. Only when find\-By\-URL() returns unknown (application/octet-stream) then this one should be used.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]The URL whose mimetype we are interested in. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The mimetype name. \end{Desc}


Definition at line 143 of file netaccess.cpp.

References mimetype\-Internal().\index{KIO::NetAccess@{KIO::Net\-Access}!lastErrorString@{lastErrorString}}
\index{lastErrorString@{lastErrorString}!KIO::NetAccess@{KIO::Net\-Access}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KIO::Net\-Access::last\-Error\-String ()\hspace{0.3cm}{\tt  [inline, static]}}\label{classKIO_1_1NetAccess_e11}


Returns the error string for the last job, in case it failed. 



Definition at line 220 of file netaccess.h.

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