KProtocolInfo Class
Information about I/O (Internet, etc.) protocols supported by KDE. More...
Header: | #include <KProtocolInfo> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
Public Types
struct | ExtraField |
ExtraFieldList | |
enum | Type { T_STREAM, T_FILESYSTEM, T_NONE, T_ERROR } |
Static Public Members
(since 5.23) QStringList | archiveMimetypes(const QString &protocol) |
QStringList | capabilities(const QString &protocol) |
QString | config(const QString &protocol) |
(since 5.60) QString | defaultMimetype(const QString &protocol) |
bool | determineMimetypeFromExtension(const QString &protocol) |
QString | docPath(const QString &protocol) |
QString | exec(const QString &protocol) |
KProtocolInfo::ExtraFieldList | extraFields(const QUrl &url) |
QString | icon(const QString &protocol) |
bool | isFilterProtocol(const QString &protocol) |
bool | isFilterProtocol(const QUrl &url) |
bool | isHelperProtocol(const QString &protocol) |
bool | isHelperProtocol(const QUrl &url) |
bool | isKnownProtocol(const QUrl &url) |
bool | isKnownProtocol(const QString &protocol, bool updateCacheIfNotfound = true) |
(since 5.101) int | maxWorkers(const QString &protocol) |
(since 5.101) int | maxWorkersPerHost(const QString &protocol) |
QString | protocolClass(const QString &protocol) |
QStringList | protocols() |
bool | showFilePreview(const QString &protocol) |
Detailed Description
* * * *
* KProtocolInfo is useful if you want to know which protocols * KDE supports. In addition you can find out lots of information * about a certain protocol. All of the functionality is provided by the static * methods. * The implementation scans the *.protocol files of all installed KIO workers to get * this information and stores the result into an internal cache. * * *.protocol files are installed in the "services" resource. * * The KProtocolInfo methods are reentrant (i.e. can be called from multiple threads simultaneously).
Member Type Documentation
KProtocolInfo::ExtraFieldList
TODO qdoc?
enum KProtocolInfo::Type
Describes the type of a protocol. For instance ftp:// appears as a filesystem with folders and files, while bzip2:// appears as a single file (a stream of data), and telnet:// doesn't output anything.
Constant | Value | Description |
---|---|---|
KProtocolInfo::T_STREAM | 0 | stream of data (e.g. single file) |
KProtocolInfo::T_FILESYSTEM | 1 | structured directory |
KProtocolInfo::T_NONE | 2 | no information about the type available |
KProtocolInfo::T_ERROR | 3 | used to signal an error |
See also outputType.
Member Function Documentation
[static, since 5.23]
QStringList KProtocolInfo::archiveMimetypes(const QString &protocol)
Returns the list of archive MIME types handled by the KIO worker implementing this protocol.
This corresponds to the "archiveMimetype=" field in the protocol description file.
protocol the protocol to check
Returns the list of archive MIME types (e.g. application/x-zip) handled.
This function was introduced in 5.23.
[static]
QStringList KProtocolInfo::capabilities(const QString &protocol)
Returns the list of capabilities provided by the KIO worker 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 worker 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 KIO worker implementations.
protocol the protocol to check
Returns the list of capabilities.
[static]
QString KProtocolInfo::config(const QString &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()
protocol the protocol to check
Returns the config file, or an empty string if unknown
[static, since 5.60]
QString KProtocolInfo::defaultMimetype(const QString &protocol)
Returns the default MIME type for the specified protocol, if one exists.
This corresponds to the "defaultMimetype=" field in the protocol description file.
protocol the protocol to check
Returns the default MIME type of the protocol, or an empty string if none set or protocol unknown
This function was introduced in 5.60.
[static]
bool KProtocolInfo::determineMimetypeFromExtension(const QString &protocol)
Returns whether MIME types 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".
protocol the protocol to check
Returns true
if the MIME types can be determined by extension
[static]
QString KProtocolInfo::docPath(const QString &protocol)
Returns the documentation path for the specified protocol.
This corresponds to the "X-DocPath=" or "DocPath=" field in the protocol description file.
protocol the protocol to check
Returns the docpath of the protocol, or an empty string if unknown
[static]
QString KProtocolInfo::exec(const QString &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.
protocol the protocol to check
Returns the executable of library to open, or QString() for unsupported protocols
See also KUrl::protocol().
[static]
KProtocolInfo::ExtraFieldList KProtocolInfo::extraFields(const QUrl &url)
Definition of extra fields in the UDS entries, returned by a listDir operation.
This corresponds to the "ExtraNames=" and "ExtraTypes=" fields in the protocol description file. Those two lists should be separated with ',' in the protocol description file. See ExtraField for details about names and types
[static]
QString KProtocolInfo::icon(const QString &protocol)
Returns the name of the icon, associated with the specified protocol.
This corresponds to the "Icon=" field in the protocol description file.
protocol the protocol to check
Returns the icon of the protocol, or an empty string if unknown
[static]
bool KProtocolInfo::isFilterProtocol(const QString &protocol)
Same as above except you can supply just the protocol instead of the whole URL.
[static]
bool KProtocolInfo::isFilterProtocol(const QUrl &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.
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
[static]
bool KProtocolInfo::isHelperProtocol(const QString &protocol)
Same as above except you can supply just the protocol instead of the whole URL.
[static]
bool KProtocolInfo::isHelperProtocol(const QUrl &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).
url the url to check
Returns true
if the protocol is a helper protocol (e.g. vnc), false if not (e.g. http)
[static]
bool KProtocolInfo::isKnownProtocol(const QUrl &url)
Returns whether a protocol is installed that is able to handle url.
url the url to check
See also name().
[static]
bool KProtocolInfo::isKnownProtocol(const QString &protocol, bool updateCacheIfNotfound = true)
Same as above except you can supply just the protocol instead of the whole URL.
[static, since 5.101]
int KProtocolInfo::maxWorkers(const QString &protocol)
Returns the soft limit on the number of KIO workers for this protocol. This limits the number of workers 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's worker metadata. The default is 1.
protocol the protocol to check
Returns the maximum number of workers, or 1 if unknown
This function was introduced in 5.101.
[static, since 5.101]
int KProtocolInfo::maxWorkersPerHost(const QString &protocol)
Returns the limit on the number of KIO workers for this protocol per host.
This corresponds to the "maxInstancesPerHost=" field in the protocol's worker metadata. The default is 0 which means there is no per host limit.
protocol the protocol to check
Returns the maximum number of workers, or 1 if unknown
This function was introduced in 5.101.
[static]
QString KProtocolInfo::protocolClass(const QString &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.
protocol the protocol to check
Returns the class of the protocol, or an empty string if unknown
[static]
QStringList KProtocolInfo::protocols()
Returns list of all known protocols.
[static]
bool KProtocolInfo::showFilePreview(const QString &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.
protocol the protocol to check
Returns true
if previews should be shown by default, false otherwise