diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2010-08-24 13:49:08 +0200 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2010-08-24 13:49:08 +0200 |
commit | 836d3f493757d14b8cc8b449a766780ee4eb1bd0 (patch) | |
tree | 78e916bbee573b0037ffb9ba1ac6a0d6abffa77f /ucbhelper | |
parent | 21755d461e133ef57386cf0d63b8bb0fb5a5dbc4 (diff) |
#i107134# - add support for https proxy server.
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/source/client/proxydecider.cxx | 239 |
1 files changed, 122 insertions, 117 deletions
diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx index 8505472e1b1f..d6fc260f558b 100644 --- a/ucbhelper/source/client/proxydecider.cxx +++ b/ucbhelper/source/client/proxydecider.cxx @@ -51,13 +51,15 @@ using namespace com::sun::star; using namespace ucbhelper; -#define CONFIG_ROOT_KEY "org.openoffice.Inet/Settings" -#define PROXY_TYPE_KEY "ooInetProxyType" -#define NO_PROXY_LIST_KEY "ooInetNoProxy" -#define HTTP_PROXY_NAME_KEY "ooInetHTTPProxyName" -#define HTTP_PROXY_PORT_KEY "ooInetHTTPProxyPort" -#define FTP_PROXY_NAME_KEY "ooInetFTPProxyName" -#define FTP_PROXY_PORT_KEY "ooInetFTPProxyPort" +#define CONFIG_ROOT_KEY "org.openoffice.Inet/Settings" +#define PROXY_TYPE_KEY "ooInetProxyType" +#define NO_PROXY_LIST_KEY "ooInetNoProxy" +#define HTTP_PROXY_NAME_KEY "ooInetHTTPProxyName" +#define HTTP_PROXY_PORT_KEY "ooInetHTTPProxyPort" +#define HTTPS_PROXY_NAME_KEY "ooInetHTTPSProxyName" +#define HTTPS_PROXY_PORT_KEY "ooInetHTTPSProxyPort" +#define FTP_PROXY_NAME_KEY "ooInetFTPProxyName" +#define FTP_PROXY_PORT_KEY "ooInetFTPProxyPort" //========================================================================= namespace ucbhelper @@ -132,6 +134,7 @@ class InternetProxyDecider_Impl : { mutable osl::Mutex m_aMutex; InternetProxyServer m_aHttpProxy; + InternetProxyServer m_aHttpsProxy; InternetProxyServer m_aFtpProxy; const InternetProxyServer m_aEmptyProxy; sal_Int32 m_nProxyType; @@ -246,6 +249,63 @@ bool WildCard::Matches( const rtl::OUString& rString ) const } //========================================================================= +bool getConfigStringValue( + const uno::Reference< container::XNameAccess > & xNameAccess, + const char * key, + rtl::OUString & value ) +{ + try + { + if ( !( xNameAccess->getByName( rtl::OUString::createFromAscii( key ) ) + >>= value ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - " + "Error getting config item value!" ); + return false; + } + } + catch ( lang::WrappedTargetException const & ) + { + return false; + } + catch ( container::NoSuchElementException const & ) + { + return false; + } + return true; +} + +//========================================================================= +bool getConfigInt32Value( + const uno::Reference< container::XNameAccess > & xNameAccess, + const char * key, + sal_Int32 & value ) +{ + try + { + uno::Any aValue = xNameAccess->getByName( + rtl::OUString::createFromAscii( key ) ); + if ( aValue.hasValue() && !( aValue >>= value ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - " + "Error getting config item value!" ); + return false; + } + } + catch ( lang::WrappedTargetException const & ) + { + return false; + } + catch ( container::NoSuchElementException const & ) + { + return false; + } + return true; +} + +//========================================================================= //========================================================================= // // InternetProxyDecider_Impl Implementation. @@ -291,127 +351,43 @@ InternetProxyDecider_Impl::InternetProxyDecider_Impl( if ( xNameAccess.is() ) { - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - PROXY_TYPE_KEY ) ) >>= m_nProxyType ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + // *** Proxy type *** + getConfigInt32Value( + xNameAccess, PROXY_TYPE_KEY, m_nProxyType ); + // *** No proxy list *** rtl::OUString aNoProxyList; - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - NO_PROXY_LIST_KEY ) ) >>= aNoProxyList ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } - + getConfigStringValue( + xNameAccess, NO_PROXY_LIST_KEY, aNoProxyList ); setNoProxyList( aNoProxyList ); - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - HTTP_PROXY_NAME_KEY ) ) - >>= m_aHttpProxy.aName ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + // *** HTTP *** + getConfigStringValue( + xNameAccess, HTTP_PROXY_NAME_KEY, m_aHttpProxy.aName ); m_aHttpProxy.nPort = -1; - try - { - uno::Any aValue = xNameAccess->getByName( - rtl::OUString::createFromAscii( - HTTP_PROXY_PORT_KEY ) ); - if ( aValue.hasValue() && - !( aValue >>= m_aHttpProxy.nPort ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } - + getConfigInt32Value( + xNameAccess, HTTP_PROXY_PORT_KEY, m_aHttpProxy.nPort ); if ( m_aHttpProxy.nPort == -1 ) m_aHttpProxy.nPort = 80; // standard HTTP port. - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - FTP_PROXY_NAME_KEY ) ) - >>= m_aFtpProxy.aName ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + // *** HTTPS *** + getConfigStringValue( + xNameAccess, HTTPS_PROXY_NAME_KEY, m_aHttpsProxy.aName ); + + m_aHttpsProxy.nPort = -1; + getConfigInt32Value( + xNameAccess, HTTPS_PROXY_PORT_KEY, m_aHttpsProxy.nPort ); + if ( m_aHttpsProxy.nPort == -1 ) + m_aHttpsProxy.nPort = 443; // standard HTTPS port. + + // *** FTP *** + getConfigStringValue( + xNameAccess, FTP_PROXY_NAME_KEY, m_aFtpProxy.aName ); m_aFtpProxy.nPort = -1; - try - { - uno::Any aValue = xNameAccess->getByName( - rtl::OUString::createFromAscii( - FTP_PROXY_PORT_KEY ) ); - if ( aValue.hasValue() && - !( aValue >>= m_aFtpProxy.nPort ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + getConfigInt32Value( + xNameAccess, FTP_PROXY_PORT_KEY, m_aFtpProxy.nPort ); } // Register as listener for config changes. @@ -588,6 +564,12 @@ const InternetProxyServer & InternetProxyDecider_Impl::getProxy( if ( m_aFtpProxy.aName.getLength() > 0 && m_aFtpProxy.nPort >= 0 ) return m_aFtpProxy; } + else if ( rProtocol.toAsciiLowerCase() + .equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "https" ) ) ) + { + if ( m_aHttpsProxy.aName.getLength() ) + return m_aHttpsProxy; + } else if ( m_aHttpProxy.aName.getLength() ) { // All other protocols use the HTTP proxy. @@ -662,6 +644,29 @@ void SAL_CALL InternetProxyDecider_Impl::changesOccurred( m_aHttpProxy.nPort = 80; // standard HTTP port. } else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( + HTTPS_PROXY_NAME_KEY ) ) ) + { + if ( !( rElem.Element >>= m_aHttpsProxy.aName ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - changesOccurred - " + "Error getting config item value!" ); + } + } + else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( + HTTPS_PROXY_PORT_KEY ) ) ) + { + if ( !( rElem.Element >>= m_aHttpsProxy.nPort ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - changesOccurred - " + "Error getting config item value!" ); + } + + if ( m_aHttpsProxy.nPort == -1 ) + m_aHttpsProxy.nPort = 443; // standard HTTPS port. + } + else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( FTP_PROXY_NAME_KEY ) ) ) { if ( !( rElem.Element >>= m_aFtpProxy.aName ) ) |