KProtocolManager Class Reference

`#include <kprotocolmanager.h>`

## 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 | noProxyForRaw ()
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@.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 54 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.

NOTE: .kionetrc files have the same format as ftp .netrc files. Please note the use of .kionetrc files is highly discouraged since password is stored in clear text. For future releases the ability to store preset password for proxy servers will probably be supported through KWallet integration.

Definition at line 194 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.

Definition at line 166 of file kprotocolmanager.h.

## Member Function Documentation

bool KProtocolManager::autoResume | ( |  | ) |

static

Returns true if partial downloads should be automatically resumed.

Returns
  true to resume partial downloads

Definition at line 508 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

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

Definition at line 283 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 180 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 189 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 120 of file kprotocolmanager.cpp.

QString KProtocolManager::defaultUserAgent | ( |  | ) |

static

Returns the default user-agent string.

Returns
  the default user-agent string

Definition at line 434 of file kprotocolmanager.cpp.

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 440 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 493 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 195 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 201 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 500 of file kprotocolmanager.cpp.

QString KProtocolManager::noProxyFor | ( |  | ) |

static

Returns a comma-separated list of hostnames or partial host-names that should bypass any proxy settings.

This function as well as useReverseProxy only apply when proxyType is `ManualProxy`.

See also
  useReverseProxy, proxyFor, proxyForURL, slaveProtocol

Definition at line 215 of file kprotocolmanager.cpp.

QString KProtocolManager::noProxyForRaw | ( |  | ) |

static

Same as above except the environment variable name is returned instead of the variable value when proxyType is `EnvVarProxy`.

See also
  noProxyFor

Since
  3.5.x

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

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

KProtocolManager::ProxyAuthMode KProtocolManager::proxyAuthMode | ( |  | ) |

static

Returns the way proxy authorization should be handled.

See also
  ProxyAuthMode

Definition at line 165 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 529 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 128 of file kprotocolmanager.cpp.

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

static

Returns the proxy server address for a given protocol.

NOTE: This function does not take the useReverseProxy() settings into account.

See also
  useReverseProxy, slaveProtocol

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

QString KProtocolManager::proxyForURL | ( | const KURL & | url | ) |

static

Returns the proxy server address for a given URL.

If proxyType returns Automatic, an external service called KPAC (a kded module) is used to determine the proxy server. Otherwise, proxyFor is invoked to determine whether the URL needs to be routed through a proxy server.

NOTE: This function does not take the useReverseProxy() or the noProxyFor() settings into account.

See also
  useReverseProxy, slaveProtocol, noProxyFor

Parameters

  url | the URL whose proxy info is needed

Returns
  the proxy server address or the text "DIRECT" if no proxying is needed for the given address.

Definition at line 238 of file kprotocolmanager.cpp.

KProtocolManager::ProxyType KProtocolManager::proxyType | ( |  | ) |

static

Returns the type of proxy configuration that is used.

See also
  ProxyType

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

void KProtocolManager::reparseConfiguration | ( |  | ) |

static

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

Definition at line 78 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 136 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

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

bool KProtocolManager::useProxy | ( |  | ) |

static

Returns true if the user specified a proxy server to make connections.

See also
  slaveProtocol, proxyForURL, proxyFor

Definition at line 146 of file kprotocolmanager.cpp.

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

bool KProtocolManager::useReverseProxy | ( |  | ) |

static

Returns true if the proxy settings should apply to the list returned by noProxyFor.

Normally addresses listed in the noProxyFor list are not routed through a proxy server. However, if this function returns true, then all addresses listed in the noProxyFor list are to be routed through a proxy server where as those that are not should bypass it.

This function as well as noProxyFor only apply when proxyType is `ManualProxy`.

See also
  proxyForURL, proxyFor, slaveProtocol

Definition at line 151 of file kprotocolmanager.cpp.

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

- kprotocolmanager.h
- kprotocolmanager.cpp

KDE Home | KDE Accessibility Home | Description of Access Keys