org.kde.koala
public class NetAccess extends QObject
UNKNOWN: Provides an easy, synchronous interface to KIO file operations.
Constructor Summary | |
---|---|
protected | NetAccess(Class dummy) |
Method Summary | |
---|---|
String | className() |
static boolean | copy(KURL src, KURL target, QWidget window)
Alternative to upload for copying over the network.
|
static boolean | del(KURL url, QWidget window)
Deletes a file or a directory in a synchronous way.
|
static boolean | dircopy(KURL src, KURL target, QWidget window)
Alternative method for copying over the network.
|
static boolean | dircopy(ArrayList src, KURL target, QWidget window)
Overloaded method, which takes a list of source URLs |
static boolean | dircopy(ArrayList src, KURL target) |
static boolean | download(KURL src, StringBuffer target, QWidget window)
Downloads a file from an arbitrary URL ( src ) to a
temporary file on the local filesystem (target ).
|
static boolean | exists(KURL url, boolean source, QWidget window)
Tests whether a URL exists. |
static boolean | file_copy(KURL src, KURL dest, int permissions, boolean overwrite, boolean resume, QWidget window)
Full-fledged equivalent of KIO.file_copy |
static boolean | file_copy(KURL src, KURL dest, int permissions, boolean overwrite, boolean resume) |
static boolean | file_copy(KURL src, KURL dest, int permissions, boolean overwrite) |
static boolean | file_copy(KURL src, KURL dest, int permissions) |
static boolean | file_copy(KURL src, KURL dest) |
static boolean | file_move(KURL src, KURL target, int permissions, boolean overwrite, boolean resume, QWidget window)
Full-fledged equivalent of KIO.file_move.
|
static boolean | file_move(KURL src, KURL target, int permissions, boolean overwrite, boolean resume) |
static boolean | file_move(KURL src, KURL target, int permissions, boolean overwrite) |
static boolean | file_move(KURL src, KURL target, int permissions) |
static boolean | file_move(KURL src, KURL target) |
static String | fish_execute(KURL url, String command, QWidget window)
Executes a remote process via the fish ioslave in a synchronous way. |
static int | lastError()
Returns the error code for the last job, in case it failed. |
static String | lastErrorString()
Returns the error string for the last job, in case it failed.
|
QMetaObject | metaObject() |
static String | mimetype(KURL url, QWidget window)
This function is not implemented! |
static boolean | mkdir(KURL url, QWidget window, int permissions)
Creates a directory in a synchronous way.
|
static boolean | mkdir(KURL url, QWidget window) |
static KURL | mostLocalURL(KURL url, QWidget window)
Tries to map a local URL for the given URL.
|
static boolean | move(KURL src, KURL target, QWidget window)
Full-fledged equivalent of KIO.move.
|
static boolean | move(KURL src, KURL target) |
static boolean | move(ArrayList src, KURL target, QWidget window)
Full-fledged equivalent of KIO.move.
|
static boolean | move(ArrayList src, KURL target) |
static void | removeTempFile(String name)
Removes the specified file if and only if it was created
by KIO.NetAccess as a temporary file for a former download.
|
static boolean | synchronousRun(Job job, QWidget window, byte[] data, KURL finalURL)
This function executes a job in a synchronous way.
|
static boolean | synchronousRun(Job job, QWidget window, byte[] data) |
static boolean | synchronousRun(Job job, QWidget window) |
static boolean | upload(String src, KURL target, QWidget window)
Uploads file src to URL target.
Both must be specified, unlike download.
|
target
exists.
This one takes two URLs and is a direct equivalent
of KIO.file_copy (not KIO.copy!).
It will be renamed file_copy in KDE4, so better use file_copy.Parameters: src URL Referencing the file to upload. target URL containing the final location of the file. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: true if successful, false for failure
UNKNOWN: Alternative to upload for copying over the network.
Parameters: url The file or directory to delete. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: true on success, false on failure.
UNKNOWN: Deletes a file or a directory in a synchronous way.
target
exists.
This one takes two URLs and is a direct equivalent
of KIO.copy!.
This means that it can copy files and directories alike
(it should have been named copy()).Parameters: src URL Referencing the file to upload. target URL containing the final location of the file. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: true if successful, false for failure
UNKNOWN: Alternative method for copying over the network.
UNKNOWN: Overloaded method, which takes a list of source URLs
src
) 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 String 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 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):
String tmpFile; if( KIO.NetAccess.download( u, tmpFile, window ) ) { loadFile( tmpFile ); KIO.NetAccess.removeTempFile( tmpFile ); } else { KMessageBox.error(this, KIO.NetAccess.lastErrorString() ); }Of course, your user interface will still process exposure/repaint events during the download. If the download fails, lastError() and lastErrorString() will be set.
Parameters: src URL Reference to the file to download. 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. Note: you are responsible for the removal of this file when you are finished reading it using removeTempFile. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: true if successful, false for failure. Use lastErrorString() to get the reason it failed.
See Also: NetAccess
UNKNOWN: Downloads a file from an arbitrary URL (src
) to a temporary file on the local filesystem (target
).
Parameters: url the URL we are testing source if true, we want to read from that URL. If false, we want to write to it. IMPORTANT: see documentation for KIO.stat for more details about this. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: true if the URL exists and we can do the operation specified by
source
, false otherwise
UNKNOWN: Tests whether a URL exists.
UNKNOWN: Full-fledged equivalent of KIO.file_copy
UNKNOWN: Full-fledged equivalent of KIO.file_move.
Parameters: url The remote machine where the command should be executed. e.g. fish://someuser\@somehost:sshport/ some special cases exist. fish://someuser\@localhost/ will use su instead of ssh to connect and execute the command. fish://someuser\@localhost:port/ will use ssh to connect and execute the command. command The command to be executed. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: The resulting output of the command
that is executed.
UNKNOWN: Executes a remote process via the fish ioslave in a synchronous way.
Returns: the last error code
UNKNOWN: Returns the error code for the last job, in case it failed.
Returns: the last error string, or null
UNKNOWN: Returns the error string for the last job, in case it failed.
Parameters: url The URL whose mimetype we are interested in. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: The mimetype name.
UNKNOWN:
KIO
.mkdir
(it saves creating a slot and testing for the job result).Parameters: url The directory to create. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed. permissions directory permissions.
Returns: true on success, false on failure.
UNKNOWN: Creates a directory in a synchronous way.
Parameters: url The URL we are testing. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: a local URL corresponding to the same ressource than the original URL, or the original URL if no local URL can be mapped
UNKNOWN: Tries to map a local URL for the given URL.
UNKNOWN: Full-fledged equivalent of KIO.move.
UNKNOWN: Full-fledged equivalent of KIO.move.
Parameters: name Path to temporary file to remove. May not be empty.
UNKNOWN: Removes the specified file if and only if it was created by KIO.NetAccess as a temporary file for a former download.
KIO.Job job = KIO.get( url, false, false );
QMap metaData;
metaData.insert( "PropagateHttpHeader", "true" );
if ( NetAccess.synchronousRun( job, 0, &data, &url, &metaData ) ) {
String responseHeaders = metaData[ "HTTP-Headers" ];
kdDebug()<<"Response header = "<< responseHeaders << endl;
}
Parameters: job job which the function will run. Note that after this function finishes running, job is deleted and you can't access it anymore! window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed. data if passed and relevant to this job then it will contain the data that was fetched by the job finalURL if passed will contain the final url of this job (it might differ from the one it was created with if there was a redirection) metaData you can pass a pointer to the map with meta data you wish to set on the job. After the job finishes this map will hold all the meta data from the job.
Returns: true on success, false on failure.
UNKNOWN: This function executes a job in a synchronous way.
src
to URL target.
Both must be specified, unlike download.
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 copy.Parameters: src URL Referencing the file to upload. target URL containing the final location of the file. window main window associated with this job. This is used to automatically cache and discard authentication information as needed. If NULL, authentication information will be cached only for a short duration after which the user will again be prompted for passwords as needed.
Returns: true if successful, false for failure
UNKNOWN: Uploads file src
to URL target.