• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

Public Types | Static Public Member Functions | List of all members
KProtocolManager Class Reference

#include <kprotocolmanager.h>

Public Types

enum  ProxyAuthMode { Prompt, Automatic }
 
enum  ProxyType {
  NoProxy, ManualProxy, PACProxy, WPADProxy,
  EnvVarProxy
}
 

Static Public Member Functions

static QString acceptLanguagesHeader ()
 
static bool autoResume ()
 
static void badProxy (const QString &proxy)
 
static KIO::CacheControl cacheControl ()
 
static QString cacheDir ()
 
static bool canCopyFromFile (const KUrl &url)
 
static bool canCopyToFile (const KUrl &url)
 
static bool canDeleteRecursive (const KUrl &url)
 
static bool canRenameFromFile (const KUrl &url)
 
static bool canRenameToFile (const KUrl &url)
 
static QString charsetFor (const KUrl &url)
 
static int connectTimeout ()
 
static QString defaultMimetype (const KUrl &url)
 
static QString defaultUserAgent ()
 
static QString defaultUserAgent (const QString &keys)
 
static
KProtocolInfo::FileNameUsedForCopying 
fileNameUsedForCopying (const KUrl &url)
 
static bool getSystemNameVersionAndMachine (QString &systemName, QString &systemVersion, QString &machine)
 
static KProtocolInfo::Type inputType (const KUrl &url)
 
static bool isSourceProtocol (const KUrl &url)
 
static QStringList listing (const KUrl &url)
 
static bool markPartial ()
 
static int maxCacheAge ()
 
static int maxCacheSize ()
 
static int minimumKeepSize ()
 
static QString noProxyFor ()
 
static KProtocolInfo::Type outputType (const KUrl &url)
 
static bool persistentConnections ()
 
static bool persistentProxyConnection ()
 
static QString protocolForArchiveMimetype (const QString &mimeType)
 
static QStringList proxiesForUrl (const KUrl &url)
 
static ProxyAuthMode proxyAuthMode ()
 
static QString proxyConfigScript ()
 
static int proxyConnectTimeout ()
 
static QString proxyFor (const QString &protocol)
 
static QString proxyForUrl (const KUrl &url)
 
static ProxyType proxyType ()
 
static int readTimeout ()
 
static void reparseConfiguration ()
 
static int responseTimeout ()
 
static QString slaveProtocol (const KUrl &url, QString &proxy)
 
static QString slaveProtocol (const KUrl &url, QStringList &proxy)
 
static bool supportsDeleting (const KUrl &url)
 
static bool supportsLinking (const KUrl &url)
 
static bool supportsListing (const KUrl &url)
 
static bool supportsMakeDir (const KUrl &url)
 
static bool supportsMoving (const KUrl &url)
 
static bool supportsOpening (const KUrl &url)
 
static bool supportsReading (const KUrl &url)
 
static bool supportsWriting (const KUrl &url)
 
static bool useCache ()
 
static bool useProxy ()
 
static QString userAgentForApplication (const QString &appName, const QString &appVersion, const QStringList &extraInfo=QStringList())
 
static QString userAgentForHost (const QString &hostname)
 
static bool useReverseProxy ()
 

Detailed Description

Provides information about I/O (Internet, etc.) settings chosen/set by the end user.

KProtocolManager has a heap of static functions that allows only read access to KDE's IO related settings. These include proxy, cache, file transfer resumption, timeout and user-agent related settings.

The information provided by this class is generic enough to be applicable to any application that makes use of KDE's IO sub-system. Note that this mean the proxy, timeout etc. settings are saved in a separate user-specific config file and not in the config file of the application.

Original author:

Author
Torben Weis weis@.nosp@m.kde..nosp@m.org

Revised by:

Author
Waldo Bastain basta.nosp@m.in@k.nosp@m.de.or.nosp@m.g
Dawit Alemayehu adawi.nosp@m.t@kd.nosp@m.e.org
See also
KPAC

Definition at line 59 of file kprotocolmanager.h.

Member Enumeration Documentation

enum KProtocolManager::ProxyAuthMode

Proxy authorization modes.

  • Prompt - Ask for authorization as needed
  • Automatic - Use auto login as defined in kionetrc files.
Enumerator
Prompt 
Automatic 

Definition at line 216 of file kprotocolmanager.h.

enum KProtocolManager::ProxyType

Types of proxy configuration.

  • NoProxy - No proxy is used
  • ManualProxy - Proxies are manually configured
  • PACProxy - A Proxy configuration URL has been given
  • WPADProxy - A proxy should be automatically discovered
  • EnvVarProxy - Use the proxy values set through environment variables.
Enumerator
NoProxy 
ManualProxy 
PACProxy 
WPADProxy 
EnvVarProxy 

Definition at line 195 of file kprotocolmanager.h.

Member Function Documentation

QString KProtocolManager::acceptLanguagesHeader ( )
static

Return Accept-Languages header built up according to user's desktop language settings.

Returns
Accept-Languages header string

Definition at line 892 of file kprotocolmanager.cpp.

bool KProtocolManager::autoResume ( )
static

Returns true if partial downloads should be automatically resumed.

Returns
true to resume partial downloads

Definition at line 968 of file kprotocolmanager.cpp.

void KProtocolManager::badProxy ( const QString &  proxy)
static

Marks this proxy as bad (down).

It will not be used for the next 30 minutes. (The script may supply an alternate proxy)

Parameters
proxythe proxy to mark as bad (as URL)

Definition at line 513 of file kprotocolmanager.cpp.

KIO::CacheControl KProtocolManager::cacheControl ( )
static

Returns the Cache control directive to be used.

Returns
the cache control value

Definition at line 331 of file kprotocolmanager.cpp.

QString KProtocolManager::cacheDir ( )
static

The directory which contains the cache files.

Returns
the directory that contains the cache files

Definition at line 339 of file kprotocolmanager.cpp.

bool KProtocolManager::canCopyFromFile ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol can copy files from the local file system

Definition at line 1113 of file kprotocolmanager.cpp.

bool KProtocolManager::canCopyToFile ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol can copy files to the local file system

Definition at line 1123 of file kprotocolmanager.cpp.

bool KProtocolManager::canDeleteRecursive ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol can delete non-empty directories by itself.

Definition at line 1151 of file kprotocolmanager.cpp.

bool KProtocolManager::canRenameFromFile ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol can rename/move files from the local file system

Definition at line 1132 of file kprotocolmanager.cpp.

bool KProtocolManager::canRenameToFile ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol can rename files to the local file system

Definition at line 1142 of file kprotocolmanager.cpp.

QString KProtocolManager::charsetFor ( const KUrl &  url)
static

Returns the charset to use for the specified url.

Since
4.10

Definition at line 1194 of file kprotocolmanager.cpp.

int KProtocolManager::connectTimeout ( )
static

Returns the preferred timeout value for remote connections in seconds.

Returns
timeout value for remote connection in secs.

Definition at line 278 of file kprotocolmanager.cpp.

QString KProtocolManager::defaultMimetype ( const KUrl &  url)
static

Returns default mimetype for this URL based on the protocol.

This corresponds to the "defaultMimetype=" field in the protocol description file.

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

Definition at line 1169 of file kprotocolmanager.cpp.

QString KProtocolManager::defaultUserAgent ( )
static

Returns the default user-agent string used for web browsing.

Returns
the default user-agent string

Definition at line 631 of file kprotocolmanager.cpp.

QString KProtocolManager::defaultUserAgent ( const QString &  keys)
static

Returns the default user-agent value used for web browsing, for example "Mozilla/5.0 (compatible; Konqueror/4.0; Linux; X11; i686; en_US) KHTML/4.0.1 (like Gecko)".

Parameters
keyscan be any of the following:
  • 'o' Show OS
  • 'v' Show OS Version
  • 'p' Show platform (only for X11)
  • 'm' Show machine architecture
  • 'l' Show language
Returns
the default user-agent value with the given keys

Definition at line 663 of file kprotocolmanager.cpp.

KProtocolInfo::FileNameUsedForCopying KProtocolManager::fileNameUsedForCopying ( const KUrl &  url)
static

This setting defines the strategy to use for generating a filename, when copying a file or directory to another directory.

By default the destination filename is made out of the filename in the source URL. However if the ioslave displays names that are different from the filename of the URL (e.g. kio_fonts shows Arial for arial.ttf, or kio_trash shows foo.txt and uses some internal URL), using Name means that the display name (UDS_NAME) will be used to as the filename in the destination directory.

This corresponds to the "fileNameUsedForCopying=" field in the protocol description file. Valid values for this field are "Name" or "FromURL" (default).

Parameters
urlthe url to check
Returns
how to generate the filename in the destination directory when copying/moving

Definition at line 1160 of file kprotocolmanager.cpp.

bool KProtocolManager::getSystemNameVersionAndMachine ( QString &  systemName,
QString &  systemVersion,
QString &  machine 
)
static

Definition at line 860 of file kprotocolmanager.cpp.

KProtocolInfo::Type KProtocolManager::inputType ( const KUrl &  url)
static

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
urlthe url to check
Returns
the input type of the given url

Definition at line 1004 of file kprotocolmanager.cpp.

bool KProtocolManager::isSourceProtocol ( const KUrl &  url)
static

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
urlthe 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)

Definition at line 1023 of file kprotocolmanager.cpp.

QStringList KProtocolManager::listing ( const KUrl &  url)
static

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
urlthe url to check
Returns
a list of field names

Definition at line 1041 of file kprotocolmanager.cpp.

bool KProtocolManager::markPartial ( )
static

Returns true if partial downloads should be marked with a ".part" extension.

Returns
true if partial downloads should get an ".part" extension

Definition at line 957 of file kprotocolmanager.cpp.

int KProtocolManager::maxCacheAge ( )
static

Returns the maximum age in seconds cached files should be kept before they are deleted as necessary.

Returns
the maximum cache age in seconds

Definition at line 344 of file kprotocolmanager.cpp.

int KProtocolManager::maxCacheSize ( )
static

Returns the maximum size that can be used for caching.

By default this function returns the DEFAULT_MAX_CACHE_SIZE value as defined in http_slave_defaults.h. Not that the value returned is in bytes, hence a value of 5120 would mean 5 Kb.

Returns
the maximum cache size in bytes

Definition at line 349 of file kprotocolmanager.cpp.

int KProtocolManager::minimumKeepSize ( )
static

Returns the minimum file size for keeping aborted downloads.

Any data downloaded that does not meet this minimum requirement will simply be discarded. The default size is 5 KB.

Returns
the minimum keep size for aborted downloads in bytes

Definition at line 962 of file kprotocolmanager.cpp.

QString KProtocolManager::noProxyFor ( )
static

Returns the strings for hosts that should contacted DIRECTLY, bypassing any proxy settings.

Returns
a list of (comma-separated) hostnames or partial host names

Definition at line 354 of file kprotocolmanager.cpp.

KProtocolInfo::Type KProtocolManager::outputType ( const KUrl &  url)
static

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
urlthe url to check
Returns
the output type of the given url

Definition at line 1013 of file kprotocolmanager.cpp.

bool KProtocolManager::persistentConnections ( )
static

Returns true if connections should be persistent.

Returns
true if the connections should be persistent

Definition at line 973 of file kprotocolmanager.cpp.

bool KProtocolManager::persistentProxyConnection ( )
static

Returns true if proxy connections should be persistent.

Returns
true if proxy connections should be persistent

Definition at line 978 of file kprotocolmanager.cpp.

QString KProtocolManager::protocolForArchiveMimetype ( const QString &  mimeType)
static

Returns which protocol handles this mimetype, if it's an archive mimetype.

For instance zip:/ handles application/x-zip.

This is defined in the protocol description file using an entry like "archiveMimetype=application/x-zip"

Parameters
mimetypethe mimetype to check
Returns
the protocol that can handle this archive mimetype, for instance "zip".
Since
4.1

Definition at line 1178 of file kprotocolmanager.cpp.

QStringList KProtocolManager::proxiesForUrl ( const KUrl &  url)
static

Returns all the possible proxy server addresses for url.

If the selected proxy type is PACProxy or WPADProxy, then a helper kded module, proxyscout, is used to determine the proxy information. Otherwise, proxyFor is used to find the proxy to use for the given url.

If this function returns empty list, then the request is to a proxy server must be denied. For a direct connection, this function will return a single entry of "DIRECT".

Since
4.7
Parameters
urlthe URL whose proxy info is needed
Returns
the proxy server address if one is available, otherwise an empty list .

Definition at line 458 of file kprotocolmanager.cpp.

KProtocolManager::ProxyAuthMode KProtocolManager::proxyAuthMode ( )
static

Returns the way proxy authorization should be handled.

Returns
the proxy authorization mode
See also
ProxyAuthMode

Definition at line 318 of file kprotocolmanager.cpp.

QString KProtocolManager::proxyConfigScript ( )
static

Returns the URL of the script for automatic proxy configuration.

Returns
the proxy configuration script

Definition at line 983 of file kprotocolmanager.cpp.

int KProtocolManager::proxyConnectTimeout ( )
static

Returns the preferred timeout value for proxy connections in seconds.

Returns
timeout value for proxy connection in secs.

Definition at line 285 of file kprotocolmanager.cpp.

QString KProtocolManager::proxyFor ( const QString &  protocol)
static

Returns the proxy server address for a given protocol.

Parameters
protocolthe protocol whose proxy info is needed
Returns
the proxy server address if one is available, or QString() if not available

Definition at line 374 of file kprotocolmanager.cpp.

QString KProtocolManager::proxyForUrl ( const KUrl &  url)
static

Returns the Proxy server address for a given URL.

If the selected proxy type is PACProxy or WPADProxy, then a helper kded module, proxyscout, is used to determine the proxy information. Otherwise, proxyFor is used to find the proxy to use for the given url.

If this function returns an empty string, then the request to a proxy server must be denied. For a direct connection, without the use of a proxy, this function will return "DIRECT".

Parameters
urlthe URL whose proxy info is needed
Returns
the proxy server address if one is available, otherwise a QString().

Definition at line 394 of file kprotocolmanager.cpp.

KProtocolManager::ProxyType KProtocolManager::proxyType ( )
static

Returns the type of proxy configuration that is used.

Returns
the proxy type

Definition at line 312 of file kprotocolmanager.cpp.

int KProtocolManager::readTimeout ( )
static

Returns the preferred timeout value for reading from remote connections in seconds.

Returns
timeout value for remote connection in secs.

Definition at line 271 of file kprotocolmanager.cpp.

void KProtocolManager::reparseConfiguration ( )
static

Force a reload of the general config file of io-slaves ( kioslaverc).

Definition at line 232 of file kprotocolmanager.cpp.

int KProtocolManager::responseTimeout ( )
static

Returns the preferred response timeout value for remote connecting in seconds.

Returns
timeout value for remote connection in seconds.

Definition at line 292 of file kprotocolmanager.cpp.

QString KProtocolManager::slaveProtocol ( const KUrl &  url,
QString &  proxy 
)
static

Return the protocol to use in order to handle the given url It's usually the same, except that FTP, when handled by a proxy, needs an HTTP ioslave.

When a proxy is to be used, proxy contains the URL for the proxy.

Parameters
urlthe url to check
proxythe URL of the proxy to use
Returns
the slave protocol (e.g. 'http'), can be null if unknown

Definition at line 525 of file kprotocolmanager.cpp.

QString KProtocolManager::slaveProtocol ( const KUrl &  url,
QStringList &  proxy 
)
static

Overloaded function that returns a list of all available proxy servers.

Since
4.7

Definition at line 548 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsDeleting ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol supports deleting

Definition at line 1077 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsLinking ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol supports linking

Definition at line 1086 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsListing ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol support listing
See also
listing()

Definition at line 1032 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsMakeDir ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol can create directories

Definition at line 1068 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsMoving ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol supports moving

Definition at line 1095 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsOpening ( const KUrl &  url)
static

Returns whether the protocol can be opened using KIO::open(const KUrl&).

This corresponds to the "opening=" field in the protocol description file. Valid values for this field are "true" or "false" (default).

Parameters
urlthe url to check
Returns
true if the protocol supports opening

Definition at line 1104 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsReading ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if it is possible to read from the URL

Definition at line 1050 of file kprotocolmanager.cpp.

bool KProtocolManager::supportsWriting ( const KUrl &  url)
static

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
urlthe url to check
Returns
true if the protocol supports writing

Definition at line 1059 of file kprotocolmanager.cpp.

bool KProtocolManager::useCache ( )
static

Returns true/false to indicate whether a cache should be used.

Returns
true to use the cache, false otherwisea

Definition at line 326 of file kprotocolmanager.cpp.

bool KProtocolManager::useProxy ( )
static

Returns whether or not the user specified the use of proxy server to make connections.

Returns
true to use a proxy

Definition at line 301 of file kprotocolmanager.cpp.

QString KProtocolManager::userAgentForApplication ( const QString &  appName,
const QString &  appVersion,
const QStringList &  extraInfo = QStringList() 
)
static

Returns the application's user-agent string.

Example string is "KMail/1.9.50 (Windows/6.0; KDE/3.97.1; i686; svn-762186; 2008-01-15)", where "KMail" is the appName parameter, "1.9.50" is the appVersion parameter, "Windows/6.0; KDE/3.97.1; i686" part is added automatically and "svn-762186; 2008-01-15" is provided by extraInfo list.

Parameters
appNamename of the application
appVersionname of the application
extraInfoa list of elements that will be appended to the string as extra information
Returns
the application's user-agent string
Since
4.1

Definition at line 828 of file kprotocolmanager.cpp.

QString KProtocolManager::userAgentForHost ( const QString &  hostname)
static

Returns the user-agent string configured for the specified host.

If hostname is not found or is empty (i.e. "" or QString()) this function will return the default user agent.

Parameters
hostnamename of the host
Returns
specified user-agent string

Definition at line 615 of file kprotocolmanager.cpp.

bool KProtocolManager::useReverseProxy ( )
static

Returns whether or not the proxy server lookup should be reversed or not.

Returns
true to use a reversed proxy

Definition at line 306 of file kprotocolmanager.cpp.


The documentation for this class was generated from the following files:
  • kprotocolmanager.h
  • kprotocolmanager.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:55 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal