org.kde.koala
Class KProtocolInfo

java.lang.Object
  extended by org.kde.koala.KShared
      extended by org.kde.koala.KSycocaEntry
          extended by org.kde.koala.KProtocolInfo
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KProtocolInfo
extends KSycocaEntry

Information about I/O (Internet, etc.) protocols supported by KDE. This class is useful if you want to know which protocols KDE supports. In addition you can find out lots of information about a certain protocol. A KProtocolInfo instance represents a single protocol. Most of the functionality is provided by the static methods that scan the .protocol files of all installed kioslaves to get this information. .protocol files are installed in the "services" resource.

Author:
Torben Weis

Field Summary
static int T_ERROR
           
static int T_FILESYSTEM
           
static int T_NONE
           
static int T_STREAM
          Describes the type of a protocol.
 
Constructor Summary
protected KProtocolInfo(java.lang.Class dummy)
           
  KProtocolInfo(org.kde.qt.QDataStream _str, int offset)
           
  KProtocolInfo(java.lang.String path)
          Read a protocol description file
 
Method Summary
static boolean canCopyFromFile(KURL url)
          Returns whether the protocol can copy files/objects directly from the filesystem itself.
static boolean canCopyToFile(KURL url)
          Returns whether the protocol can copy files/objects directly to the filesystem itself.
protected  boolean canDeleteRecursive()
           
static boolean canDeleteRecursive(KURL url)
          Returns whether the protocol can recursively delete directories by itself.
protected  boolean canRenameFromFile()
           
static boolean canRenameFromFile(KURL url)
          Returns whether the protocol can rename (i.e.
protected  boolean canRenameToFile()
           
static boolean canRenameToFile(KURL url)
          Returns whether the protocol can rename (i.e.
static java.util.ArrayList capabilities(java.lang.String protocol)
          Returns the list of capabilities provided by the kioslave implementing this protocol.
static java.lang.String config(java.lang.String protocol)
          Returns the name of the config file associated with the specified protocol.
static java.lang.String defaultMimetype(KURL url)
          Returns default mimetype for this URL based on the protocol.
static boolean determineMimetypeFromExtension(java.lang.String protocol)
          Returns whether mimetypes can be determined based on extension for this protocol.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
static java.lang.String docPath(java.lang.String protocol)
          Returns the documentation path for the specified protocol.
static java.lang.String exec(java.lang.String protocol)
          Returns the library / executable to open for the protocol protocol Example : "kio_ftp", meaning either the executable "kio_ftp" or the library "kio_ftp.la" (recommended), whichever is available.
protected  void finalize()
          Deletes the wrapped C++ instance
protected static KProtocolInfo findProtocol(KURL url)
           
static java.lang.String icon(java.lang.String protocol)
          Returns the name of the icon, associated with the specified protocol.
static int inputType(KURL url)
          Returns whether the protocol should be treated as a filesystem or as a stream when reading from it.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
static boolean isFilterProtocol(KURL url)
          Returns whether the protocol can act as a filter protocol.
static boolean isFilterProtocol(java.lang.String protocol)
          Same as above except you can supply just the protocol instead of the whole URL.
static boolean isHelperProtocol(KURL url)
          Returns whether the protocol can act as a helper protocol.
static boolean isHelperProtocol(java.lang.String protocol)
          Same as above except you can supply just the protocol instead of the whole URL.
static boolean isKnownProtocol(KURL url)
          Returns whether a protocol is installed that is able to handle url.
static boolean isKnownProtocol(java.lang.String protocol)
          Same as above except you can supply just the protocol instead of the whole URL.
static boolean isSourceProtocol(KURL url)
          Returns whether the protocol can act as a source protocol.
 boolean isValid()
          Returns whether the protocol description file is valid.
static java.util.ArrayList listing(KURL url)
          Returns the list of fields this protocol returns when listing The current possibilities are Name, Type, Size, Date, AccessDate, Access, Owner, Group, Link, URL, MimeType as well as Extra1, Extra2 etc.
 void load(org.kde.qt.QDataStream arg1)
          Load the protocol info from a stream.
static int maxSlaves(java.lang.String protocol)
          Returns the soft limit on the number of slaves for this protocol.
 java.lang.String name()
          Returns the name of the protocol.
static int outputType(KURL url)
          Returns whether the protocol should be treated as a filesystem or as a stream when writing to it.
static java.lang.String protocolClass(java.lang.String protocol)
          Returns the protocol class for the specified protocol.
static java.util.ArrayList protocols()
          Returns list of all known protocols.
static java.lang.String proxiedBy(java.lang.String protocol)
          Returns the name of the protocol through which the request will be routed if proxy support is enabled.
 void save(org.kde.qt.QDataStream arg1)
          Save the protocol info to a stream.
static boolean showFilePreview(java.lang.String protocol)
          Returns whether file previews should be shown for the specified protocol.
static boolean supportsDeleting(KURL url)
          Returns whether the protocol can delete files/objects.
static boolean supportsLinking(KURL url)
          Returns whether the protocol can create links between files/objects.
static boolean supportsListing(KURL url)
          Returns whether the protocol can list files/objects.
static boolean supportsMakeDir(KURL url)
          Returns whether the protocol can create directories/folders.
static boolean supportsMoving(KURL url)
          Returns whether the protocol can move files/objects between different locations.
static boolean supportsReading(KURL url)
          Returns whether the protocol can retrieve data from URLs.
static boolean supportsWriting(KURL url)
          Returns whether the protocol can store data to URLs.
static int uriParseMode(java.lang.String protocol)
          Returns the suggested URI parsing mode for the KURL parser.
 
Methods inherited from class org.kde.koala.KSycocaEntry
entryPath, isDeleted, isType, offset, read, read, sycocaType
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

T_STREAM

public static final int T_STREAM
Describes the type of a protocol.

See Also:
Constant Field Values

T_FILESYSTEM

public static final int T_FILESYSTEM
See Also:
Constant Field Values

T_NONE

public static final int T_NONE
See Also:
Constant Field Values

T_ERROR

public static final int T_ERROR
See Also:
Constant Field Values
Constructor Detail

KProtocolInfo

protected KProtocolInfo(java.lang.Class dummy)

KProtocolInfo

public KProtocolInfo(java.lang.String path)
Read a protocol description file

Parameters:
path - the path of the description file

KProtocolInfo

public KProtocolInfo(org.kde.qt.QDataStream _str,
                     int offset)
Method Detail

isValid

public boolean isValid()
Returns whether the protocol description file is valid.

Overrides:
isValid in class KSycocaEntry
Returns:
true if valid, false otherwise

name

public java.lang.String name()
Returns the name of the protocol. This corresponds to the "protocol=" field in the protocol description file.

Overrides:
name in class KSycocaEntry
Returns:
the name of the protocol
See Also:
KURL.protocol()

load

public void load(org.kde.qt.QDataStream arg1)
Load the protocol info from a stream.

Overrides:
load in class KSycocaEntry

save

public void save(org.kde.qt.QDataStream arg1)
Save the protocol info to a stream.

Overrides:
save in class KSycocaEntry

protocols

public static java.util.ArrayList protocols()
Returns list of all known protocols.

Returns:
a list of all known protocols

isKnownProtocol

public static boolean isKnownProtocol(KURL url)
Returns whether a protocol is installed that is able to handle url.

Parameters:
url - the url to check
Returns:
true if the protocol is known
See Also:
name()

isKnownProtocol

public static boolean isKnownProtocol(java.lang.String protocol)
Same as above except you can supply just the protocol instead of the whole URL.


exec

public static java.lang.String exec(java.lang.String protocol)
Returns the library / executable to open for the protocol protocol Example : "kio_ftp", meaning either the executable "kio_ftp" or the library "kio_ftp.la" (recommended), whichever is available. This corresponds to the "exec=" field in the protocol description file.

Parameters:
protocol - the protocol to check
Returns:
the executable of library to open, or null for unsupported protocols
See Also:
KURL.protocol()

inputType

public static int inputType(KURL url)
Returns whether the protocol should be treated as a filesystem or as a stream when reading from it. This corresponds to the "input=" field in the protocol description file. Valid values for this field are "filesystem", "stream" or "none" (default).

Parameters:
url - the url to check
Returns:
the input type of the given url

outputType

public static int outputType(KURL url)
Returns whether the protocol should be treated as a filesystem or as a stream when writing to it. This corresponds to the "output=" field in the protocol description file. Valid values for this field are "filesystem", "stream" or "none" (default).

Parameters:
url - the url to check
Returns:
the output type of the given url

listing

public static java.util.ArrayList listing(KURL url)
Returns the list of fields this protocol returns when listing The current possibilities are Name, Type, Size, Date, AccessDate, Access, Owner, Group, Link, URL, MimeType as well as Extra1, Extra2 etc. for extra fields (see extraFields). This corresponds to the "listing=" field in the protocol description file. The supported fields should be separated with ',' in the protocol description file.

Parameters:
url - the url to check
Returns:
a list of field names

isSourceProtocol

public static boolean isSourceProtocol(KURL url)
Returns whether the protocol can act as a source protocol. A source protocol retrieves data from or stores data to the location specified by a URL. A source protocol is the opposite of a filter protocol. The "source=" field in the protocol description file determines whether a protocol is a source protocol or a filter protocol.

Parameters:
url - the url to check
Returns:
true if the protocol is a source of data (e.g. http), false if the protocol is a filter (e.g. gzip)

isHelperProtocol

public static boolean isHelperProtocol(KURL url)
Returns whether the protocol can act as a helper protocol. A helper protocol invokes an external application and does not return a file or stream. This corresponds to the "helper=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol is a helper protocol (e.g. vnc), false if not (e.g. http)

isHelperProtocol

public static boolean isHelperProtocol(java.lang.String protocol)
Same as above except you can supply just the protocol instead of the whole URL.


isFilterProtocol

public static boolean isFilterProtocol(KURL url)
Returns whether the protocol can act as a filter protocol. A filter protocol can operate on data that is passed to it but does not retrieve/store data itself, like gzip. A filter protocol is the opposite of a source protocol. The "source=" field in the protocol description file determines whether a protocol is a source protocol or a filter protocol. Valid values for this field are "true" (default) for source protocol or "false" for filter protocol.

Parameters:
url - the url to check
Returns:
true if the protocol is a filter (e.g. gzip), false if the protocol is a helper or source

isFilterProtocol

public static boolean isFilterProtocol(java.lang.String protocol)
Same as above except you can supply just the protocol instead of the whole URL.


supportsListing

public static boolean supportsListing(KURL url)
Returns whether the protocol can list files/objects. If a protocol supports listing it can be browsed in e.g. file-dialogs and konqueror. Whether a protocol supports listing is determined by the "listing=" field in the protocol description file. If the protocol support listing it should list the fields it provides in this field. If the protocol does not support listing this field should remain empty (default.)

Parameters:
url - the url to check
Returns:
true if the protocol support listing
See Also:
listing(org.kde.koala.KURL)

supportsReading

public static boolean supportsReading(KURL url)
Returns whether the protocol can retrieve data from URLs. This corresponds to the "reading=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if it is possible to read from the URL

supportsWriting

public static boolean supportsWriting(KURL url)
Returns whether the protocol can store data to URLs. This corresponds to the "writing=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol supports writing

supportsMakeDir

public static boolean supportsMakeDir(KURL url)
Returns whether the protocol can create directories/folders. This corresponds to the "makedir=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol can create directories

supportsDeleting

public static boolean supportsDeleting(KURL url)
Returns whether the protocol can delete files/objects. This corresponds to the "deleting=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol supports deleting

supportsLinking

public static boolean supportsLinking(KURL url)
Returns whether the protocol can create links between files/objects. This corresponds to the "linking=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol supports linking

supportsMoving

public static boolean supportsMoving(KURL url)
Returns whether the protocol can move files/objects between different locations. This corresponds to the "moving=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol supports moving

canCopyFromFile

public static boolean canCopyFromFile(KURL url)
Returns whether the protocol can copy files/objects directly from the filesystem itself. If not, the application will read files from the filesystem using the file-protocol and pass the data on to the destination protocol. This corresponds to the "copyFromFile=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol can copy files from the local file system

canCopyToFile

public static boolean canCopyToFile(KURL url)
Returns whether the protocol can copy files/objects directly to the filesystem itself. If not, the application will receive the data from the source protocol and store it in the filesystem using the file-protocol. This corresponds to the "copyToFile=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol can copy files to the local file system

canRenameFromFile

public static boolean canRenameFromFile(KURL url)
Returns whether the protocol can rename (i.e. move fast) files/objects directly from the filesystem itself. If not, the application will read files from the filesystem using the file-protocol and pass the data on to the destination protocol. This corresponds to the "renameFromFile=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol can rename/move files from the local file system

canRenameToFile

public static boolean canRenameToFile(KURL url)
Returns whether the protocol can rename (i.e. move fast) files/objects directly to the filesystem itself. If not, the application will receive the data from the source protocol and store it in the filesystem using the file-protocol. This corresponds to the "renameToFile=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol can rename files to the local file system

canDeleteRecursive

public static boolean canDeleteRecursive(KURL url)
Returns whether the protocol can recursively delete directories by itself. If not (the usual case) then KIO will list the directory and delete files and empty directories one by one. This corresponds to the "deleteRecursive=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters:
url - the url to check
Returns:
true if the protocol can delete non-empty directories by itself.

defaultMimetype

public static java.lang.String defaultMimetype(KURL url)
Returns default mimetype for this URL based on the protocol. This corresponds to the "defaultMimetype=" field in the protocol description file.

Parameters:
url - the url to check
Returns:
the default mime type of the protocol, or null if unknown

icon

public static java.lang.String icon(java.lang.String protocol)
Returns the name of the icon, associated with the specified protocol. This corresponds to the "Icon=" field in the protocol description file.

Parameters:
protocol - the protocol to check
Returns:
the icon of the protocol, or null if unknown

config

public static java.lang.String config(java.lang.String protocol)
Returns the name of the config file associated with the specified protocol. This is useful if two similar protocols need to share a single config file, e.g. http and https. This corresponds to the "config=" field in the protocol description file. The default is the protocol name, see name()

Parameters:
protocol - the protocol to check
Returns:
the config file, or null if unknown

maxSlaves

public static int maxSlaves(java.lang.String protocol)
Returns the soft limit on the number of slaves for this protocol. This limits the number of slaves used for a single operation, note that multiple operations may result in a number of instances that exceeds this soft limit. This corresponds to the "maxInstances=" field in the protocol description file. The default is 1.

Parameters:
protocol - the protocol to check
Returns:
the maximum number of slaves, or 1 if unknown

determineMimetypeFromExtension

public static boolean determineMimetypeFromExtension(java.lang.String protocol)
Returns whether mimetypes can be determined based on extension for this protocol. For some protocols, e.g. http, the filename extension in the URL can not be trusted to truly reflect the file type. This corresponds to the "determineMimetypeFromExtension=" field in the protocol description file. Valid values for this field are "true" (default) or "false".

Parameters:
protocol - the protocol to check
Returns:
true if the mime types can be determined by extension

docPath

public static java.lang.String docPath(java.lang.String protocol)
Returns the documentation path for the specified protocol. This corresponds to the "DocPath=" field in the protocol description file.

Parameters:
protocol - the protocol to check
Returns:
the docpath of the protocol, or null if unknown

protocolClass

public static java.lang.String protocolClass(java.lang.String protocol)
Returns the protocol class for the specified protocol. This corresponds to the "Class=" field in the protocol description file. The following classes are defined:
  • ":internet" for common internet protocols
  • ":local" for protocols that access local resources
  • Protocol classes always start with a ':' so that they can not be confused with the protocols themselves.

    Parameters:
    protocol - the protocol to check
    Returns:
    the class of the protocol, or null if unknown

    showFilePreview

    public static boolean showFilePreview(java.lang.String protocol)
    Returns whether file previews should be shown for the specified protocol. This corresponds to the "ShowPreviews=" field in the protocol description file. By default previews are shown if protocolClass is :local.

    Parameters:
    protocol - the protocol to check
    Returns:
    true if previews should be shown by default, false otherwise

    uriParseMode

    public static int uriParseMode(java.lang.String protocol)
    Returns the suggested URI parsing mode for the KURL parser. This corresponds to the "URIMode=" field in the protocol description file. The following parsing modes are defined:
  • "url" for a standards compliant URL
  • "rawuri" for a non-conformant URI for which URL parsing would be meaningless
  • "mailto" for a mailto style URI (the path part contains only an email address)
  • Parameters:
    protocol - the protocol to check
    Returns:
    the suggested parsing mode, or KURL.Auto if unspecified

    capabilities

    public static java.util.ArrayList capabilities(java.lang.String protocol)
    Returns the list of capabilities provided by the kioslave implementing this protocol. This corresponds to the "Capabilities=" field in the protocol description file. The capability names are not defined globally, they are up to each slave implementation. For example when adding support for a new special command for mounting, one would add the string "Mount" to the capabilities list, and applications could check for that string before sending a special() command that would otherwise do nothing on older kioslave implementations.

    Parameters:
    protocol - the protocol to check
    Returns:
    the list of capabilities.

    proxiedBy

    public static java.lang.String proxiedBy(java.lang.String protocol)
    Returns the name of the protocol through which the request will be routed if proxy support is enabled. A good example of this is the ftp protocol for which proxy support is commonly handled by the http protocol. This corresponds to the "ProxiedBy=" in the protocol description file.


    canRenameFromFile

    protected boolean canRenameFromFile()

    canRenameToFile

    protected boolean canRenameToFile()

    canDeleteRecursive

    protected boolean canDeleteRecursive()

    findProtocol

    protected static KProtocolInfo findProtocol(KURL url)

    finalize

    protected void finalize()
                     throws java.lang.InternalError
    Deletes the wrapped C++ instance

    Overrides:
    finalize in class java.lang.Object
    Throws:
    java.lang.InternalError

    dispose

    public void dispose()
    Delete the wrapped C++ instance ahead of finalize()


    isDisposed

    public boolean isDisposed()
    Has the wrapped C++ instance been deleted?