# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KProtocolManager Class Reference

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

`#include <kprotocolmanager.h>`

List of all members.

## Public Types

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

## Static Public Member Functions

static QString | defaultUserAgent ()
static QString | defaultUserAgent (const QString &keys)
static QString | userAgentForHost (const QString &hostname)
static int | readTimeout ()
static int | connectTimeout ()
static int | proxyConnectTimeout ()
static int | responseTimeout ()
static bool | useProxy ()
static bool | useReverseProxy ()
static ProxyType | proxyType ()
static ProxyAuthMode | proxyAuthMode ()
static QString | noProxyFor ()
static QString | proxyFor (const QString &protocol)
static QString | proxyForURL (const KURL &url)
static void | badProxy (const QString &proxy)
static QString | proxyConfigScript ()
static bool | useCache ()
static int | maxCacheAge ()
static int | maxCacheSize ()
static QString | cacheDir ()
static KIO::CacheControl | cacheControl ()
static bool | autoResume ()
static bool | markPartial ()
static int | minimumKeepSize ()
static bool | persistentProxyConnection ()
static bool | persistentConnections ()
static void | reparseConfiguration ()
static QString | slaveProtocol (const KURL &url, QString &proxy)
static KConfig * | config ()

## 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@kde.org>

Revised by:

Author:
  Waldo Bastain <bastain@kde.org>

  Dawit Alemayehu <adawit@kde.org>

See also:
  KPAC

Definition at line 54 of file kprotocolmanager.h.

## Member Enumeration Documentation

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.

Definition at line 157 of file kprotocolmanager.h.

enum KProtocolManager::ProxyAuthMode

Proxy authorization modes.

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

Definition at line 178 of file kprotocolmanager.h.

## Member Function Documentation

QString KProtocolManager::defaultUserAgent | ( |  | ) | `[static]`

Returns the default user-agent string.

Returns:
  the default user-agent string

Definition at line 431 of file kprotocolmanager.cpp.

Referenced by userAgentForHost().

QString KProtocolManager::defaultUserAgent | ( | const QString & | keys | ) | `[static]`

Returns the default user-agent value.

Parameters:

  keys

  can be any of the following:
  - 'o' Show OS
  - 'v' Show OS Version
  - 'p' Show platform
  - 'm' Show machine architecture
  - 'l' Show language

Returns:
  the default user-agent value with the given `keys`

Definition at line 437 of file kprotocolmanager.cpp.

References QString::arg(), QString::contains(), QString::fromLatin1(), QString::isEmpty(), QStringList::join(), KLocale::languageList(), and KGlobal::locale().

QString KProtocolManager::userAgentForHost | ( | const QString & | hostname | ) | `[static]`

Returns the userAgent string configured for the specified host.

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

Parameters:

  | hostname | name of the host

Returns:
  specified userAgent string

Definition at line 415 of file kprotocolmanager.cpp.

References defaultUserAgent(), QString::isEmpty(), and QString::lower().

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 112 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry(), and KConfigBase::setGroup().

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 120 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry(), and KConfigBase::setGroup().

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 128 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry(), and KConfigBase::setGroup().

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 136 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry(), and KConfigBase::setGroup().

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 146 of file kprotocolmanager.cpp.

References proxyType().

bool KProtocolManager::useReverseProxy | ( |  | ) | `[static]`

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

Returns:
  true to use a reversed proxy

Definition at line 151 of file kprotocolmanager.cpp.

References KConfigBase::readBoolEntry(), and KConfigBase::setGroup().

KProtocolManager::ProxyType KProtocolManager::proxyType | ( |  | ) | `[static]`

Returns the type of proxy configuration that is used.

Returns:
  the proxy type

Definition at line 158 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry(), and KConfigBase::setGroup().

Referenced by noProxyFor(), proxyForURL(), and useProxy().

KProtocolManager::ProxyAuthMode KProtocolManager::proxyAuthMode | ( |  | ) | `[static]`

Returns the way proxy authorization should be handled.

Returns:
  the proxy authorization mode

See also:
  ProxyAuthMode

Definition at line 165 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry(), and KConfigBase::setGroup().

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 207 of file kprotocolmanager.cpp.

References QString::fromLocal8Bit(), QString::local8Bit(), proxyType(), KConfigBase::readEntry(), and KConfigBase::setGroup().

QString KProtocolManager::proxyFor | ( | const QString & | protocol | ) | `[static]`

Returns the proxy server address for a given protocol.

Parameters:

  | protocol | the protocol whose proxy info is needed

Returns:
  the proxy server address if one is available, or QString::null if not available

Definition at line 221 of file kprotocolmanager.cpp.

References QString::lower(), KConfigBase::readEntry(), and KConfigBase::setGroup().

Referenced by proxyForURL().

QString KProtocolManager::proxyForURL | ( | const KURL & | url | ) | `[static]`

Returns the Proxy server address for a given URL If automatic proxy configuration is configured, KPAC is used to determine the proxy server, otherwise the return value of proxyFor for the URL's protocol is used.

If an empty string is returned, the request is to be aborted, a return value of "DIRECT" requests a direct connection.

Parameters:

  | url | the URL whose proxy info is needed

Returns:
  the proxy server address if one is available or QString::null otherwise

Definition at line 235 of file kprotocolmanager.cpp.

References QString::fromLatin1(), QString::fromLocal8Bit(), QString::isEmpty(), QString::local8Bit(), QString::lower(), KURL::protocol(), proxyFor(), proxyType(), KURL::setProtocol(), QString::startsWith(), and QString::stripWhiteSpace().

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:

  | proxy | the proxy to mark as bad (as URL)

Definition at line 280 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 525 of file kprotocolmanager.cpp.

References KConfigBase::readEntry(), and KConfigBase::setGroup().

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 174 of file kprotocolmanager.cpp.

References KConfigBase::readBoolEntry().

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 195 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry().

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 201 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry().

QString KProtocolManager::cacheDir | ( |  | ) | `[static]`

The directory which contains the cache files.

Returns:
  the directory that contains the cache files

Definition at line 189 of file kprotocolmanager.cpp.

References KConfigBase::readPathEntry().

KIO::CacheControl KProtocolManager::cacheControl | ( |  | ) | `[static]`

Returns the Cache control directive to be used.

Returns:
  the cache control value

Definition at line 180 of file kprotocolmanager.cpp.

References QString::isEmpty(), KIO::parseCacheControl(), and KConfigBase::readEntry().

bool KProtocolManager::autoResume | ( |  | ) | `[static]`

Returns true if partial downloads should be automatically resumed.

Returns:
  true to resume partial downloads

Definition at line 504 of file kprotocolmanager.cpp.

References KConfigBase::readBoolEntry(), and KConfigBase::setGroup().

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 489 of file kprotocolmanager.cpp.

References KConfigBase::readBoolEntry(), and KConfigBase::setGroup().

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 496 of file kprotocolmanager.cpp.

References KConfigBase::readNumEntry(), and KConfigBase::setGroup().

bool KProtocolManager::persistentProxyConnection | ( |  | ) | `[static]`

Returns true if proxy connections should be persistent.

Returns:
  true if proxy connections should be persistent

Since:
  3.1

Definition at line 518 of file kprotocolmanager.cpp.

References KConfigBase::readBoolEntry(), and KConfigBase::setGroup().

bool KProtocolManager::persistentConnections | ( |  | ) | `[static]`

Returns true if connections should be persistent.

Returns:
  true if the connections should be persistent

Definition at line 511 of file kprotocolmanager.cpp.

References KConfigBase::readBoolEntry(), and KConfigBase::setGroup().

void KProtocolManager::reparseConfiguration | ( |  | ) | `[static]`

| Force a reload of the general config file of io-slaves ( kioslaverc). Definition at line 78 of file kprotocolmanager.cpp. References KStaticDeleter< type >::destructObject().

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:

  | url | the url to check
  | proxy | the URL of the proxy to use

Returns:
  the slave protocol (e.g. 'http'), can be null if unknown

Definition at line 326 of file kprotocolmanager.cpp.

References endl(), QValueList::fromLast(), QString::isEmpty(), kdDebug(), QString::latin1(), QString::lower(), QString::number(), KURL::split(), QString::startsWith(), and QString::stripWhiteSpace().

The documentation for this class was generated from the following files:

- kprotocolmanager.h
- kprotocolmanager.cpp

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:25:12 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003