<HTML> <HEAD> <TITLE>class NetAccess</TITLE> <META NAME="Generator" CONTENT="KDOC "> </HEAD> <BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff"> <TABLE WIDTH="100%" BORDER="0"> <TR> <TD> <TABLE BORDER="0"> <TR><TD valign="top" align="left" cellspacing="10"> <h1>class NetAccess</h1> </TD> <TD valign="top" align="right" colspan="1">Provides a synchronous interface to io jobs. <small><A HREF="#longdesc">More...</A></small></TD></TR> </TABLE> <HR> <TABLE BORDER="0"> <TR><TH>Full name</TH><TD><code><A HREF="KIO.html">KIO</A>::NetAccess</code></TD></TR> <TR><TH>Definition</TH><TD><code>#include <<A HREF="netaccess_h.html">netaccess.h</A>></code></TD></TR> <TR><TH>Inherits</TH><TD><A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qobject.html">QObject</A> <small>(qt)</small> <small>[public ]</small></TD></TR> <TR><TH><A HREF="full-list-KIO__NetAccess.html">List of all Methods</A></TH></TR> </TABLE> </TD> <TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR> <TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR> <TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR> <TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR> <TR><TD><small><A HREF="index.html">Index</A></small></TD></TR> </TABLE></TD></TR></TABLE> <h4>Public Static Methods</h4><ul><LI>static bool <b><A HREF="#ref1">download</A></b> (const <A HREF="../kdecore/KURL.html">KURL</A>& src, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> & target) </LI> <LI>static void <b><A HREF="#ref2">removeTempFile</A></b> (const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A>& name) </LI> <LI>static bool <b><A HREF="#ref3">upload</A></b> (const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A>& src, const <A HREF="../kdecore/KURL.html">KURL</A>& target) </LI> <LI>static bool <b><A HREF="#ref4">copy</A></b> ( const <A HREF="../kdecore/KURL.html">KURL</A>& src, const <A HREF="../kdecore/KURL.html">KURL</A>& target ) </LI> <LI>static bool <b><A HREF="#ref5">dircopy</A></b> ( const <A HREF="../kdecore/KURL.html">KURL</A>& src, const <A HREF="../kdecore/KURL.html">KURL</A>& target ) </LI> <LI>static bool <b><A HREF="#ref6">exists</A></b> (const <A HREF="../kdecore/KURL.html">KURL</A>& url) </LI> <LI>static bool <b><A HREF="#ref7">stat</A></b> (const <A HREF="../kdecore/KURL.html">KURL</A>& url, <A HREF="KIO.html#UDSEntry">KIO::UDSEntry</A> & entry) </LI> <LI>static bool <b><A HREF="#ref8">del</A></b> ( const <A HREF="../kdecore/KURL.html">KURL</A> & url ) </LI> <LI>static bool <b><A HREF="#ref9">mkdir</A></b> ( const <A HREF="../kdecore/KURL.html">KURL</A> & url, int permissions = -1 ) </LI> <LI>static <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> <b><A HREF="#ref10">mimetype</A></b> ( const <A HREF="../kdecore/KURL.html">KURL</A> & url ) </LI> <LI>static <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> <b><A HREF="#ref11">lastErrorString</A></b> () </LI> </ul><HR><H2><A NAME="longdesc">Detailed Description</A></H2><p> Net Transparency, formerly provided by kfmlib, but now done with KIO::Jobs. </p> <p> 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 <code>kiojob</code> is asynchronous, meaning that the developer has to connect slots for it, <code>KIO::NetAccess</code> provides synchronous downloads and uploads, as well as temporary file creation and removal. </p> <p> Port to kio done by David Faure, faure@kde.org </p> <p></p> <A NAME="download"></A><A NAME="ref1"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>download</strong> (const <A HREF="../kdecore/KURL.html">KURL</A>& src, <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> & target) <br></td><td align="right"><h3><strong>download</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Download a file from an arbitrary URL (<code>src</code>) to a temporary file on the local filesystem (<code>target</code>). </p> <p> If the argument for <code>target</code> is an empty string, download will generate a unique temporary filename in /tmp. Since <code>target</code> is a reference to <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> you can access this filename easily. Download will return <code>true</code> if the download was successful, otherwise <code>false</code>. </p> <p> Special case: If the URL is of kind <code>file:</code> then no downloading is processed but the full filename is returned in <code>target</code>. That means you <em>have</em> to take care about the <code>target</code> argument. (This is very easy to do, please see the example below.) </p> <p> Download is synchronous. That means you can use it like this, (assuming <code>u</code> is a string which represents a URL and your application has a loadFile() function): </p> <p></p><table border="0" width="100%"> <tr> <td bgcolor="#BEEAE0"> <pre> <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> tmpFile; if( <A HREF="KIO__NetAccess.html#download">KIO::NetAccess::download</A>( u, tmpFile ) ) { loadFile( tmpFile ); <A HREF="KIO__NetAccess.html#removeTempFile">KIO::NetAccess::removeTempFile</A>( tmpFile ); } </pre> </td></tr> </table> <p> </p> <p> Of course, your user interface will still process exposure/repaint events during the download. </p> <p></p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>src</i></TD><TD align="left" valign="top">URL Reference to the file to download. </TD></TR> <TR><TD align="left" valign="top"><i>target</i></TD><TD align="left" valign="top">String containing the final local location of the file. If you insert an empty string, it will return a location in a temporary spot. </TD></TR> </TABLE></P> <A NAME="removeTempFile"></A><A NAME="ref2"></A><table width="100%"><tr bgcolor="#eeeeee"><td> void <strong>removeTempFile</strong> (const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A>& name) <br></td><td align="right"><h3><strong>removeTempFile</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Remove the specified file if and only if it was created by <A HREF="KIO__NetAccess.html">KIO::NetAccess</A> as a temporary file for a former download. </p> <p> Note: This means that if you created your temporary with <A HREF="../kdecore/KTempFile.html">KTempFile</A>, use <A HREF="../kdecore/KTempFile.html#unlink">KTempFile::unlink</A>() or <A HREF="../kdecore/KTempFile.html#setAutoDelete">KTempFile::setAutoDelete</A>() to have it removed. </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>name</i></TD><TD align="left" valign="top">Path to temporary file to remove. May not be empty. </TD></TR> </TABLE></P> <A NAME="upload"></A><A NAME="ref3"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>upload</strong> (const <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A>& src, const <A HREF="../kdecore/KURL.html">KURL</A>& target) <br></td><td align="right"><h3><strong>upload</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Upload file <code>src</code> to URL <code>target</code>. </p> <p> Both must be specified, unlike <A HREF="KIO__NetAccess.html#download">download</A>. 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 <A HREF="KIO__NetAccess.html#copy">copy</A>. </p> <p></p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>src</i></TD><TD align="left" valign="top">URL Referencing the file to upload. </TD></TR> <TR><TD align="left" valign="top"><i>target</i></TD><TD align="left" valign="top">URL containing the final location of the file. </TD></TR> </TABLE></P> <A NAME="copy"></A><A NAME="ref4"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>copy</strong> ( const <A HREF="../kdecore/KURL.html">KURL</A>& src, const <A HREF="../kdecore/KURL.html">KURL</A>& target ) <br></td><td align="right"><h3><strong>copy</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Alternative method for copying over the network. Overwrite is false, so this will fail if <code>target</code> exists. </p> <p> This one takes two URLs and is a direct equivalent of <A HREF="KIO.html#file_copy">KIO::file_copy</A> (not KIO::copy!). </p> <A NAME="dircopy"></A><A NAME="ref5"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>dircopy</strong> ( const <A HREF="../kdecore/KURL.html">KURL</A>& src, const <A HREF="../kdecore/KURL.html">KURL</A>& target ) <br></td><td align="right"><h3><strong>dircopy</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Alternative method for copying over the network. Overwrite is false, so this will fail if <code>target</code> exists. </p> <p> This one takes two URLs and is a direct equivalent of <A HREF="KIO.html#copy">KIO::copy</A>!. </p> <A NAME="exists"></A><A NAME="ref6"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>exists</strong> (const <A HREF="../kdecore/KURL.html">KURL</A>& url) <br></td><td align="right"><h3><strong>exists</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Test whether a URL exists. </p> <p> This is a convenience function for <A HREF="KIO.html#stat">KIO::stat</A> (it saves creating a slot and testing for the job result). </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>url</i></TD><TD align="left" valign="top">the url we are testing </TD></TR> </TABLE></P> <A NAME="stat"></A><A NAME="ref7"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>stat</strong> (const <A HREF="../kdecore/KURL.html">KURL</A>& url, <A HREF="KIO.html#UDSEntry">KIO::UDSEntry</A> & entry) <br></td><td align="right"><h3><strong>stat</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Test whether a URL exists and return information on it. </p> <p> This is a convenience function for <A HREF="KIO.html#stat">KIO::stat</A> (it saves creating a slot and testing for the job result). </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>url</i></TD><TD align="left" valign="top">The URL we are testing. </TD></TR> <TR><TD align="left" valign="top"><i>entry</i></TD><TD align="left" valign="top">The result of the stat. Iterate over the list of atoms to get hold of name, type, size, etc., or use <A HREF="KFileItem.html">KFileItem</A>. </TD></TR> </TABLE></P> <A NAME="del"></A><A NAME="ref8"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>del</strong> ( const <A HREF="../kdecore/KURL.html">KURL</A> & url ) <br></td><td align="right"><h3><strong>del</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Delete a file or a directory in an synchronous way. </p> <p> This is a convenience function for <A HREF="KIO.html#del">KIO::del</A> (it saves creating a slot and testing for the job result). </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>url</i></TD><TD align="left" valign="top">The file or directory to delete. </TD></TR> </TABLE></P> <p><b>Returns</b>: <code>true</code> on success, <code>false</code> on failure. </p> <A NAME="mkdir"></A><A NAME="ref9"></A><table width="100%"><tr bgcolor="#eeeeee"><td> bool <strong>mkdir</strong> ( const <A HREF="../kdecore/KURL.html">KURL</A> & url, int permissions = -1 ) <br></td><td align="right"><h3><strong>mkdir</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Create a directory in an synchronous way. </p> <p> This is a convenience function for <code>KIO::mkdir</code> (it saves creating a slot and testing for the job result). </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>url</i></TD><TD align="left" valign="top">The directory to create. </TD></TR> </TABLE></P> <p><b>Returns</b>: <code>true</code> on success, <code>false</code> on failure. </p> <A NAME="mimetype"></A><A NAME="ref10"></A><table width="100%"><tr bgcolor="#eeeeee"><td> <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> <strong>mimetype</strong> ( const <A HREF="../kdecore/KURL.html">KURL</A> & url ) <br></td><td align="right"><h3><strong>mimetype</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Determine the mimetype of a given URL. </p> <p> This is a convenience function for <A HREF="KIO.html#mimetype">KIO::mimetype</A>. You should call this only when really necessary. <A HREF="KMimeType.html#findByURL">KMimeType::findByURL</A> can determine extension a lot faster, but less reliably for remote files. Only when findByURL() returns unknown (application/octet-stream) then this one should be used. </p> <p></p> <p><b>Parameters</b>:<TABLE BORDER="0" CELLPADDING="5"> <TR><TD align="left" valign="top"><i>url</i></TD><TD align="left" valign="top">The URL whose mimetype we are interested in. </TD></TR> </TABLE></P> <p><b>Returns</b>: The mimetype name. </p> <A NAME="lastErrorString"></A><A NAME="ref11"></A><table width="100%"><tr bgcolor="#eeeeee"><td> <A HREF="../../../../../../../../../usr/share/doc/qt-2.3.1/html/qstring.html">QString</A> <strong>lastErrorString</strong> () <br></td><td align="right"><h3><strong>lastErrorString</strong></h3></td></tr></table><p> <small>[static]</small></p><p> Return error string for the last job, in case it failed </p> <HR> <table> <tr><td><small>Generated by: qateam on updates.mandrakesoft.com on Mon Dec 30 16:09:14 2002, using kdoc 2.0a53.</small></td></tr> </table> </BODY> </HTML>