class KIONetAccess

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

Definition#include <kio_netaccess.h>
InheritsQObject (kdecore)
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Static Methods

Protected Methods

Protected Slots

Protected Members


Detailed Description

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. KIONetAccess implements the Net Transparency, which was formerly provided by kfmlib, but now using KIOJobs. Whereas a kiojob is asynchronous, meaning that the developer has to connect slots for it, KIONetAccess provides synchronous downloads and uploads, as well as temporary file creation and removal.

Port to kio done by David Faure, faure@kde.org

bool download (const QString src, QString & target, KIOJob *job = 0L)
[static]

This function downloads a file from an arbitrary URL (source) to a temporary file on the local filesystem (target). If the argument for target is an empty string, download will generate a unique temporary filename in /tmp. Since target is a reference to 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 returned in target. That means: you _have_ to take care about the 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 u is a string which represents a URL and your application has a loadFile function):


 QString s;
 if( KIONetAccess::download( u, s ) )
 {
   loadFile( s );
   KIONetAccess::removeTempFile( s );
 }

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

Parameters:
srcURL referencing the file to download
targetString containing the final local location of the file. If you insert an empty string, it will return a location in a temporary spot
jobFor experts only. You may supply your own KIOJob object if you want to do some special processing with it before or after the download

void removeTempFile (const QString name)
[static]

Remove the specified file if and only if it was created by KIONetAccess as temporary file for a former download.

Parameters:
namePath to temporary file to remove. May not be empty.

bool upload (const QString src, const QString target, KIOJob *job = 0L)
[static]

Upload file src to url target. Both must be specified, unlike download.

Parameters:
srcURL referencing the file to upload
targetURL containing the final location of the file.
jobFor experts only. You may supply your own KIOJob object if you want to do some special processing with it before or after the download

KIONetAccess ()
[protected]

Private constructor

~KIONetAccess ()
[protected]

Private destructor

bool downloadInternal (const QString src, QString & target, KIOJob *job = 0L)
[protected]

Internal method

static QStringList* tmpfiles
[protected]

List of temporary files

bool bDownloadOk
[protected]

Whether the download succeeded or not


Generated by: root@tantive.terraplex.com on Sun Feb 27 17:39:31 2000, using kdoc 2.0a33.