org.kde.koala

Class KProtocolManager

public class KProtocolManager extends Object implements QtSupport

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: Revised by:

Author: Dawit Alemayehu

See Also: KPAC

UNKNOWN: Provides information about I/O (Internet, etc.

Field Summary
static intAutomatic
static intEnvVarProxy
static intManualProxy
static intNoProxy
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.
  • static intPACProxy
    static intPrompt
    Proxy authorization modes.
    static intWPADProxy
    Constructor Summary
    protected KProtocolManager(Class dummy)
    KProtocolManager()
    Method Summary
    static booleanautoResume()
    Returns true if partial downloads should be automatically resumed.
    static voidbadProxy(String proxy)
    Marks this proxy as bad (down).
    static intcacheControl()
    Returns the Cache control directive to be used.
    static StringcacheDir()
    The directory which contains the cache files.
    static KConfigconfig()
    (Shared with SlaveConfig)
    static intconnectTimeout()
    Returns the preferred timeout value for remote connections in seconds.
    static StringdefaultUserAgent()
    Returns the default user-agent string.
    static StringdefaultUserAgent(String keys)
    Returns the default user-agent value.
    voiddispose()
    Delete the wrapped C++ instance ahead of finalize()
    protected voidfinalize()
    Deletes the wrapped C++ instance
    booleanisDisposed()
    Has the wrapped C++ instance been deleted?
    static booleanmarkPartial()
    Returns true if partial downloads should be marked with a ".part" extension.
    static intmaxCacheAge()
    Returns the maximum age in seconds cached files should be kept before they are deleted as necessary.
    static intmaxCacheSize()
    Returns the maximum size that can be used for caching.
    static intminimumKeepSize()
    Returns the minimum file size for keeping aborted downloads.
    static StringnoProxyFor()
    Returns a comma-separated list of hostnames or partial host-names that should bypass any proxy settings.
    static booleanpersistentConnections()
    Returns true if connections should be persistent
    static booleanpersistentProxyConnection()
    Returns true if proxy connections should be persistent.
    static intproxyAuthMode()
    Returns the way proxy authorization should be handled.
    static StringproxyConfigScript()
    Returns the URL of the script for automatic proxy configuration.
    static intproxyConnectTimeout()
    Returns the preferred timeout value for proxy connections in seconds.
    static StringproxyFor(String protocol)
    Returns the proxy server address for a given protocol.
    static StringproxyForURL(KURL url)
    Returns the proxy server address for a given URL.
    static intproxyType()
    Returns the type of proxy configuration that is used.
    static intreadTimeout()
    Returns the preferred timeout value for reading from remote connections in seconds.
    static voidreparseConfiguration()
    Force a reload of the general config file of io-slaves ( kioslaverc).
    static intresponseTimeout()
    Returns the preferred response timeout value for remote connecting in seconds.
    static StringslaveProtocol(KURL url, StringBuffer proxy)
    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.
    static booleanuseCache()
    Returns true/false to indicate whether a cache should be used
    static booleanuseProxy()
    Returns true if the user specified a proxy server to make connections.
    static StringuserAgentForHost(String hostname)
    Returns the userAgent string configured for the specified host.
    static booleanuseReverseProxy()
    Returns true if the proxy settings should apply to the list returned by KProtocolManager.

    Field Detail

    Automatic

    public static final int Automatic

    EnvVarProxy

    public static final int EnvVarProxy

    ManualProxy

    public static final int ManualProxy

    NoProxy

    public static final int NoProxy
    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.
  • @short Types of proxy configuration

    PACProxy

    public static final int PACProxy

    Prompt

    public static final int Prompt
    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.

    UNKNOWN: Proxy authorization modes.

    WPADProxy

    public static final int WPADProxy

    Constructor Detail

    KProtocolManager

    protected KProtocolManager(Class dummy)

    KProtocolManager

    public KProtocolManager()

    Method Detail

    autoResume

    public static boolean autoResume()
    Returns true if partial downloads should be automatically resumed.

    Returns: true to resume partial downloads

    UNKNOWN: Returns true if partial downloads should be automatically resumed.

    badProxy

    public static void badProxy(String proxy)
    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)

    UNKNOWN: Marks this proxy as bad (down).

    cacheControl

    public static int cacheControl()
    Returns the Cache control directive to be used.

    Returns: the cache control value

    UNKNOWN: Returns the Cache control directive to be used.

    cacheDir

    public static String cacheDir()
    The directory which contains the cache files.

    Returns: the directory that contains the cache files

    UNKNOWN: The directory which contains the cache files.

    config

    public static KConfig config()
    (Shared with SlaveConfig)

    UNKNOWN:

    connectTimeout

    public static int connectTimeout()
    Returns the preferred timeout value for remote connections in seconds.

    Returns: timeout value for remote connection in secs.

    UNKNOWN: Returns the preferred timeout value for remote connections in seconds.

    defaultUserAgent

    public static String defaultUserAgent()
    Returns the default user-agent string.

    Returns: the default user-agent string

    UNKNOWN: Returns the default user-agent string.

    defaultUserAgent

    public static String defaultUserAgent(String keys)
    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

    UNKNOWN: Returns the default user-agent value.

    dispose

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

    finalize

    protected void finalize()
    Deletes the wrapped C++ instance

    isDisposed

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

    markPartial

    public static boolean markPartial()
    Returns true if partial downloads should be marked with a ".part" extension.

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

    UNKNOWN: Returns true if partial downloads should be marked with a ".

    maxCacheAge

    public static int maxCacheAge()
    Returns the maximum age in seconds cached files should be kept before they are deleted as necessary.

    Returns: the maximum cache age in seconds

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

    maxCacheSize

    public static int maxCacheSize()
    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

    UNKNOWN: Returns the maximum size that can be used for caching.

    minimumKeepSize

    public static int minimumKeepSize()
    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

    UNKNOWN: Returns the minimum file size for keeping aborted downloads.

    noProxyFor

    public static String noProxyFor()
    Returns a comma-separated list of hostnames or partial host-names that should bypass any proxy settings. This function as well as KProtocolManager only apply when KProtocolManager is ManualProxy.

    See Also: KProtocolManager KProtocolManager KProtocolManager KProtocolManager

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

    persistentConnections

    public static boolean persistentConnections()
    Returns true if connections should be persistent

    Returns: true if the connections should be persistent

    UNKNOWN: Returns true if connections should be persistent

    persistentProxyConnection

    public static boolean persistentProxyConnection()
    Returns true if proxy connections should be persistent.

    Returns: true if proxy connections should be persistent

    UNKNOWN: Returns true if proxy connections should be persistent.

    proxyAuthMode

    public static int proxyAuthMode()
    Returns the way proxy authorization should be handled.

    See Also: ProxyAuthMode

    UNKNOWN: Returns the way proxy authorization should be handled.

    proxyConfigScript

    public static String proxyConfigScript()
    Returns the URL of the script for automatic proxy configuration.

    Returns: the proxy configuration script

    UNKNOWN: Returns the URL of the script for automatic proxy configuration.

    proxyConnectTimeout

    public static int proxyConnectTimeout()
    Returns the preferred timeout value for proxy connections in seconds.

    Returns: timeout value for proxy connection in secs.

    UNKNOWN: Returns the preferred timeout value for proxy connections in seconds.

    proxyFor

    public static String proxyFor(String protocol)
    Returns the proxy server address for a given protocol. NOTE: This function does not take the KProtocolManager settings into account.

    Parameters: protocol the protocol whose proxy info is needed

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

    See Also: KProtocolManager KProtocolManager

    UNKNOWN: Returns the proxy server address for a given protocol.

    proxyForURL

    public static String proxyForURL(KURL url)
    Returns the proxy server address for a given URL. If KProtocolManager returns Automatic, an external service called KPAC (a kded module) is used to determine the proxy server. Otherwise, KProtocolManager is invoked to determine whether the URL needs to be routed through a proxy server. NOTE: This function does not take the KProtocolManager or the KProtocolManager settings into account.

    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.

    See Also: KProtocolManager KProtocolManager KProtocolManager

    UNKNOWN: Returns the proxy server address for a given URL.

    proxyType

    public static int proxyType()
    Returns the type of proxy configuration that is used.

    See Also: ProxyType

    UNKNOWN: Returns the type of proxy configuration that is used.

    readTimeout

    public static int readTimeout()
    Returns the preferred timeout value for reading from remote connections in seconds.

    Returns: timeout value for remote connection in secs.

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

    reparseConfiguration

    public static void reparseConfiguration()
    Force a reload of the general config file of io-slaves ( kioslaverc).

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

    responseTimeout

    public static int responseTimeout()
    Returns the preferred response timeout value for remote connecting in seconds.

    Returns: timeout value for remote connection in seconds.

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

    slaveProtocol

    public static String slaveProtocol(KURL url, StringBuffer proxy)
    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

    UNKNOWN: 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.

    useCache

    public static boolean useCache()
    Returns true/false to indicate whether a cache should be used

    Returns: true to use the cache, false otherwisea

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

    useProxy

    public static boolean useProxy()
    Returns true if the user specified a proxy server to make connections.

    See Also: KProtocolManager KProtocolManager KProtocolManager

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

    userAgentForHost

    public static String userAgentForHost(String hostname)
    Returns the userAgent string configured for the specified host. If hostname is not found or is empty (i.e. "" or null) this function will return the default user agent.

    Parameters: hostname name of the host

    Returns: specified userAgent string

    UNKNOWN: Returns the userAgent string configured for the specified host.

    useReverseProxy

    public static boolean useReverseProxy()
    Returns true if the proxy settings should apply to the list returned by KProtocolManager. 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 KProtocolManager only apply when KProtocolManager is ManualProxy.

    See Also: KProtocolManager KProtocolManager KProtocolManager

    UNKNOWN: Returns true if the proxy settings should apply to the list returned by @ref noProxyFor.