org.kde.koala
Class KProtocolManager

java.lang.Object
  extended by org.kde.koala.KProtocolManager
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KProtocolManager
extends java.lang.Object
implements org.kde.qt.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

Field Summary
static int Automatic
           
static int EnvVarProxy
           
static int ManualProxy
           
static 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.
static int PACProxy
           
static int Prompt
          Proxy authorization modes.
static int WPADProxy
           
 
Constructor Summary
  KProtocolManager()
           
protected KProtocolManager(java.lang.Class dummy)
           
 
Method Summary
static boolean autoResume()
          Returns true if partial downloads should be automatically resumed.
static void badProxy(java.lang.String proxy)
          Marks this proxy as bad (down).
static int cacheControl()
          Returns the Cache control directive to be used.
static java.lang.String cacheDir()
          The directory which contains the cache files.
static KConfig config()
          (Shared with SlaveConfig)
static int connectTimeout()
          Returns the preferred timeout value for remote connections in seconds.
static java.lang.String defaultUserAgent()
          Returns the default user-agent string.
static java.lang.String defaultUserAgent(java.lang.String keys)
          Returns the default user-agent value.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
protected  void finalize()
          Deletes the wrapped C++ instance
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
static boolean markPartial()
          Returns true if partial downloads should be marked with a ".part" extension.
static int maxCacheAge()
          Returns the maximum age in seconds cached files should be kept before they are deleted as necessary.
static int maxCacheSize()
          Returns the maximum size that can be used for caching.
static int minimumKeepSize()
          Returns the minimum file size for keeping aborted downloads.
static java.lang.String noProxyFor()
          Returns a comma-separated list of hostnames or partial host-names that should bypass any proxy settings.
static boolean persistentConnections()
          Returns true if connections should be persistent
static boolean persistentProxyConnection()
          Returns true if proxy connections should be persistent.
static int proxyAuthMode()
          Returns the way proxy authorization should be handled.
static java.lang.String proxyConfigScript()
          Returns the URL of the script for automatic proxy configuration.
static int proxyConnectTimeout()
          Returns the preferred timeout value for proxy connections in seconds.
static java.lang.String proxyFor(java.lang.String protocol)
          Returns the proxy server address for a given protocol.
static java.lang.String proxyForURL(KURL url)
          Returns the proxy server address for a given URL.
static int proxyType()
          Returns the type of proxy configuration that is used.
static int readTimeout()
          Returns the preferred timeout value for reading from remote connections in seconds.
static void reparseConfiguration()
          Force a reload of the general config file of io-slaves ( kioslaverc).
static int responseTimeout()
          Returns the preferred response timeout value for remote connecting in seconds.
static java.lang.String slaveProtocol(KURL url, java.lang.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 boolean useCache()
          Returns true/false to indicate whether a cache should be used
static boolean useProxy()
          Returns true if the user specified a proxy server to make connections.
static java.lang.String userAgentForHost(java.lang.String hostname)
          Returns the userAgent string configured for the specified host.
static boolean useReverseProxy()
          Returns true if the proxy settings should apply to the list returned by noProxyFor().
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

    See Also:
    Constant Field Values

    ManualProxy

    public static final int ManualProxy
    See Also:
    Constant Field Values

    PACProxy

    public static final int PACProxy
    See Also:
    Constant Field Values

    WPADProxy

    public static final int WPADProxy
    See Also:
    Constant Field Values

    EnvVarProxy

    public static final int EnvVarProxy
    See Also:
    Constant Field Values

    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.

    See Also:
    Constant Field Values

    Automatic

    public static final int Automatic
    See Also:
    Constant Field Values
    Constructor Detail

    KProtocolManager

    protected KProtocolManager(java.lang.Class dummy)

    KProtocolManager

    public KProtocolManager()
    Method Detail

    defaultUserAgent

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

    Returns:
    the default user-agent string

    defaultUserAgent

    public static java.lang.String defaultUserAgent(java.lang.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

    userAgentForHost

    public static java.lang.String userAgentForHost(java.lang.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

    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.

    connectTimeout

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

    Returns:
    timeout value for remote connection in secs.

    proxyConnectTimeout

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

    Returns:
    timeout value for proxy connection in secs.

    responseTimeout

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

    Returns:
    timeout value for remote connection in seconds.

    useProxy

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

    See Also:
    slaveProtocol(org.kde.koala.KURL, java.lang.StringBuffer), proxyForURL(org.kde.koala.KURL), proxyFor(java.lang.String)

    useReverseProxy

    public static boolean useReverseProxy()
    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(org.kde.koala.KURL), proxyFor(java.lang.String), slaveProtocol(org.kde.koala.KURL, java.lang.StringBuffer)

    proxyType

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

    See Also:
    ProxyType

    proxyAuthMode

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

    See Also:
    ProxyAuthMode

    noProxyFor

    public static java.lang.String noProxyFor()
    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(java.lang.String), proxyForURL(org.kde.koala.KURL), slaveProtocol(org.kde.koala.KURL, java.lang.StringBuffer)

    proxyFor

    public static java.lang.String proxyFor(java.lang.String protocol)
    Returns the proxy server address for a given protocol. NOTE: This function does not take the useReverseProxy() 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:
    useReverseProxy(), slaveProtocol(org.kde.koala.KURL, java.lang.StringBuffer)

    proxyForURL

    public static java.lang.String proxyForURL(KURL url)
    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(java.lang.String) 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.

    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:
    useReverseProxy(), slaveProtocol(org.kde.koala.KURL, java.lang.StringBuffer), noProxyFor()

    badProxy

    public static void badProxy(java.lang.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)

    proxyConfigScript

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

    Returns:
    the proxy configuration script

    useCache

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

    Returns:
    true to use the cache, false otherwisea

    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

    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

    cacheDir

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

    Returns:
    the directory that contains the cache files

    cacheControl

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

    Returns:
    the cache control value

    autoResume

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

    Returns:
    true to resume partial downloads

    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

    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

    persistentProxyConnection

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

    Returns:
    true if proxy connections should be persistent

    persistentConnections

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

    Returns:
    true if the connections should be persistent

    reparseConfiguration

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


    slaveProtocol

    public static java.lang.String slaveProtocol(KURL url,
                                                 java.lang.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

    config

    public static KConfig config()
    (Shared with SlaveConfig)


    finalize

    protected void finalize()
                     throws java.lang.InternalError
    Deletes the wrapped C++ instance

    Overrides:
    finalize in class java.lang.Object
    Throws:
    java.lang.InternalError

    dispose

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


    isDisposed

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