.TH "KIO::NetAccess" 3 "28 Jan 2004" "kio Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KIO::NetAccess \- Net Transparency, formerly provided by kfmlib, but now done with \fBKIO::Job\fP. Provides a synchronous interface to io jobs.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <netaccess.h>\fP
.PP
Inherits \fBQObject\fP.
.PP
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "bool \fBdownload\fP (const  \fBKURL\fP &src, \fBQString\fP &target)"
.br
.RI "\fIDownloads a file from an arbitrary URL (\fCsrc\fP) to a temporary file on the local filesystem (\fCtarget\fP). \fP"
.ti -1c
.RI "void \fBremoveTempFile\fP (const  \fBQString\fP &\fBname\fP)"
.br
.RI "\fIRemoves the specified file if and only if it was created by KIO::NetAccess as a temporary file for a former download. \fP"
.ti -1c
.RI "bool \fBupload\fP (const  \fBQString\fP &src, const  \fBKURL\fP &target)"
.br
.RI "\fIUploads file \fCsrc\fP to URL \fCtarget\fP. \fP"
.ti -1c
.RI "bool \fBcopy\fP (const  \fBKURL\fP &src, const  \fBKURL\fP &target)"
.br
.RI "\fIAlternative method for copying over the network. \fP"
.ti -1c
.RI "bool \fBdircopy\fP (const  \fBKURL\fP &src, const  \fBKURL\fP &target)"
.br
.RI "\fIAlternative method for copying over the network. \fP"
.ti -1c
.RI "bool \fBexists\fP (const  \fBKURL\fP &url)"
.br
.RI "\fITests whether a URL exists. \fP"
.ti -1c
.RI "bool \fBexists\fP (const  \fBKURL\fP &url, bool source)"
.br
.RI "\fIOverloaded version of exists A \fBstat()\fP can have two meanings. \fP"
.ti -1c
.RI "bool \fBstat\fP (const  \fBKURL\fP &url, \fBKIO::UDSEntry\fP &entry)"
.br
.RI "\fITests whether a URL exists and return information on it. \fP"
.ti -1c
.RI "bool \fBdel\fP (const  \fBKURL\fP &url)"
.br
.RI "\fIDeletes a file or a directory in an synchronous way. \fP"
.ti -1c
.RI "bool \fBmkdir\fP (const  \fBKURL\fP &url, int permissions=-1)"
.br
.RI "\fICreates a directory in a synchronous way. \fP"
.ti -1c
.RI "\fBQString\fP \fBmimetype\fP (const  \fBKURL\fP &url)"
.br
.RI "\fIDetermines the mimetype of a given URL. \fP"
.ti -1c
.RI "\fBQString\fP \fBlastErrorString\fP ()"
.br
.RI "\fIReturns the error string for the last job, in case it failed. \fP"
.in -1c
.SS "Friends"

.in +1c
.ti -1c
.RI "class \fBI_like_this_class\fP"
.br
.in -1c
.SH "Detailed Description"
.PP 
Net Transparency, formerly provided by kfmlib, but now done with \fBKIO::Job\fP. 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 \fBKIO::Job\fP is asynchronous, meaning that the developer has to connect slots for it, KIO::NetAccess provides synchronous downloads and uploads, as well as temporary file creation and removal.
.PP
Port to kio done by David Faure, faure@kde.org
.PP
Definition at line 52 of file netaccess.h.
.SH "Member Function Documentation"
.PP 
.SS "bool NetAccess::download (const \fBKURL\fP & src, \fBQString\fP & target)\fC [static]\fP"
.PP
Downloads a file from an arbitrary URL (\fCsrc\fP) to a temporary file on the local filesystem (\fCtarget\fP). If the argument for \fCtarget\fP is an empty string, download will generate a unique temporary filename in /tmp. Since \fCtarget\fP is a reference to \fBQString\fP you can access this filename easily. Download will return true if the download was successful, otherwise false.
.PP
Special case: If the URL is of kind file:, then no downloading is processed but the full filename is returned in \fCtarget\fP. That means you \fIhave\fP to take care about the \fCtarget\fP argument. (This is very easy to do, please see the example below.)
.PP
Download is synchronous. That means you can use it like this, (assuming \fCu\fP is a string which represents a URL and your application has a \fBloadFile\fP() function):
.PP
.PP
.nf

 \fBQString\fP tmpFile;
 if( KIO::NetAccess::download( u, tmpFile ) )
 {
   loadFile( tmpFile );
   KIO::NetAccess::removeTempFile( tmpFile );
   }
 
.PP
.PP
Of course, your user interface will still process exposure/repaint events during the download.
.PP
\fBParameters:\fP
.RS 4
\fIsrc\fP URL Reference to the file to download.
.br
\fItarget\fP String containing the final local location of the file. If you insert an empty string, it will return a location in a temporary spot. 
.RE
.PP
Definition at line 47 of file netaccess.cpp.
.PP
References QString::arg(), copyInternal(), QString::isEmpty(), KURL::isLocalFile(), KTempFile::name(), KURL::path(), and KURL::setPath().
.SS "void NetAccess::removeTempFile (const \fBQString\fP & name)\fC [static]\fP"
.PP
Removes the specified file if and only if it was created by KIO::NetAccess as a temporary file for a former download. Note: This means that if you created your temporary with \fBKTempFile\fP, use \fBKTempFile::unlink\fP() or \fBKTempFile::setAutoDelete\fP() to have it removed.
.PP
\fBParameters:\fP
.RS 4
\fIname\fP Path to temporary file to remove. May not be empty. 
.RE
.PP
Definition at line 151 of file netaccess.cpp.
.PP
References QFile::encodeName(), and KStdAccel::name().
.SS "bool NetAccess::upload (const \fBQString\fP & src, const \fBKURL\fP & target)\fC [static]\fP"
.PP
Uploads file \fCsrc\fP to URL \fCtarget\fP. Both must be specified, unlike \fBdownload\fP. 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 \fBcopy\fP.
.PP
\fBParameters:\fP
.RS 4
\fIsrc\fP URL Referencing the file to upload.
.br
\fItarget\fP URL containing the final location of the file. 
.RE
.PP
Definition at line 77 of file netaccess.cpp.
.PP
References copyInternal(), KURL::isEmpty(), KURL::isLocalFile(), KURL::path(), and KURL::setPath().
.SS "bool NetAccess::copy (const \fBKURL\fP & src, const \fBKURL\fP & target)\fC [static]\fP"
.PP
Alternative method for copying over the network. Overwrite is false, so this will fail if \fCtarget\fP exists.
.PP
This one takes two URLs and is a direct equivalent of \fBKIO::file_copy\fP (not \fBKIO::copy\fP!). Definition at line 94 of file netaccess.cpp.
.PP
References copyInternal().
.SS "bool NetAccess::dircopy (const \fBKURL\fP & src, const \fBKURL\fP & target)\fC [static]\fP"
.PP
Alternative method for copying over the network. Overwrite is false, so this will fail if \fCtarget\fP exists.
.PP
This one takes two URLs and is a direct equivalent of \fBKIO::copy\fP!. Definition at line 100 of file netaccess.cpp.
.PP
References dircopyInternal().
.SS "bool NetAccess::exists (const \fBKURL\fP & url)\fC [static]\fP"
.PP
Tests whether a URL exists. This is a convenience function for \fBKIO::stat\fP (it saves creating a slot and testing for the job result).
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP the url we are testing 
.RE
.PP
Definition at line 106 of file netaccess.cpp.
.PP
References QFile::exists(), KURL::isLocalFile(), KURL::path(), and statInternal().
.SS "bool NetAccess::exists (const \fBKURL\fP & url, bool source)\fC [static]\fP"
.PP
Overloaded version of exists A \fBstat()\fP can have two meanings. Either we want to read from this URL, or to check if we can write to it. First case is 'source', second is 'dest'. It is necessary to know what the StatJob is for, to tune the kioslave's behaviour (e.g. with FTP) Tests whether a URL exists.
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP the url we are testing 
.br
\fIsource\fP if true, we want to read from that URL. If false, we want to write to it. 
.RE
.PP
Definition at line 114 of file netaccess.cpp.
.PP
References QFile::exists(), KURL::isLocalFile(), KURL::path(), and statInternal().
.SS "bool NetAccess::stat (const \fBKURL\fP & url, \fBKIO::UDSEntry\fP & entry)\fC [static]\fP"
.PP
Tests whether a URL exists and return information on it. This is a convenience function for \fBKIO::stat\fP (it saves creating a slot and testing for the job result).
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP The URL we are testing. 
.br
\fIentry\fP The result of the stat. Iterate over the list of atoms to get hold of name, type, size, etc., or use \fBKFileItem\fP. 
.RE
.PP
Definition at line 122 of file netaccess.cpp.
.PP
References m_entry, statInternal(), and KIO::UDSEntry.
.SS "bool NetAccess::del (const \fBKURL\fP & url)\fC [static]\fP"
.PP
Deletes a file or a directory in an synchronous way. This is a convenience function for \fBKIO::del\fP (it saves creating a slot and testing for the job result).
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP The file or directory to delete. 
.RE
.PP
\fBReturns:\fP
.RS 4
\fCtrue\fP on success, \fCfalse\fP on failure. 
.RE
.PP
Definition at line 131 of file netaccess.cpp.
.PP
References delInternal().
.SS "bool NetAccess::mkdir (const \fBKURL\fP & url, int permissions = -1)\fC [static]\fP"
.PP
Creates a directory in a synchronous way. This is a convenience function for \fC\fBKIO::mkdir\fP\fP (it saves creating a slot and testing for the job result).
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP The directory to create. 
.RE
.PP
\fBReturns:\fP
.RS 4
\fCtrue\fP on success, \fCfalse\fP on failure. 
.RE
.PP
Definition at line 137 of file netaccess.cpp.
.PP
References mkdirInternal().
.PP
Referenced by KDirOperator::mkdir().
.SS "\fBQString\fP NetAccess::mimetype (const \fBKURL\fP & url)\fC [static]\fP"
.PP
Determines the mimetype of a given URL. This is a convenience function for \fBKIO::mimetype\fP. You should call this only when really necessary. \fBKMimeType::findByURL\fP can determine extension a lot faster, but less reliably for remote files. Only when \fBfindByURL\fP() returns unknown (application/octet-stream) then this one should be used.
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP The URL whose mimetype we are interested in. 
.RE
.PP
\fBReturns:\fP
.RS 4
The mimetype name. 
.RE
.PP
Definition at line 143 of file netaccess.cpp.
.PP
References mimetypeInternal().
.SS "\fBQString\fP KIO::NetAccess::lastErrorString ()\fC [inline, static]\fP"
.PP
Returns the error string for the last job, in case it failed. Definition at line 220 of file netaccess.h.

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